common/cnxk: fix Coverity issues

Message ID 20240228064643.1923169-1-psatheesh@marvell.com (mailing list archive)
State Changes Requested, archived
Delegated to: Jerin Jacob
Headers
Series common/cnxk: fix Coverity issues |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-sample-apps-testing success Testing PASS

Commit Message

Satheesh Paul Antonysamy Feb. 28, 2024, 6:46 a.m. UTC
  From: Satheesh Paul <psatheesh@marvell.com>

Fix Out-of-bounds access and remove dead code
reported by Coverity.

Coverity issue: 384431, 384439, 380992
Fixes: 585bb3e538f9 ("common/cnxk: add VF support to base device class")
Fixes: da1ec39060b2 ("common/cnxk: delay inline device RQ enable to dev start")
Cc: stable@dpdk.org

Signed-off-by: Satheesh Paul <psatheesh@marvell.com>
Reviewed-by: Nithin Dabilpuram <ndabilpuram@marvell.com>
Reviewed-by: Harman Kalra <hkalra@marvell.com>
---
 drivers/common/cnxk/roc_dev.c     | 2 ++
 drivers/common/cnxk/roc_nix_inl.c | 3 +--
 2 files changed, 3 insertions(+), 2 deletions(-)
  

Comments

Jerin Jacob Feb. 29, 2024, 6:31 p.m. UTC | #1
On Wed, Feb 28, 2024 at 12:25 PM <psatheesh@marvell.com> wrote:
>
> From: Satheesh Paul <psatheesh@marvell.com>


Please change the subject "common/cnxk: fix Coverity issues" and align
on what is fixed and send as separate patches.



> Fix Out-of-bounds access and remove dead code
> reported by Coverity.
>
> Coverity issue: 384431, 384439, 380992
> Fixes: 585bb3e538f9 ("common/cnxk: add VF support to base device class")
> Fixes: da1ec39060b2 ("common/cnxk: delay inline device RQ enable to dev start")
> Cc: stable@dpdk.org
>
> Signed-off-by: Satheesh Paul <psatheesh@marvell.com>
> Reviewed-by: Nithin Dabilpuram <ndabilpuram@marvell.com>
> Reviewed-by: Harman Kalra <hkalra@marvell.com>
> ---
>  drivers/common/cnxk/roc_dev.c     | 2 ++
>  drivers/common/cnxk/roc_nix_inl.c | 3 +--
>  2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/common/cnxk/roc_dev.c b/drivers/common/cnxk/roc_dev.c
> index 084343c3b4..14aff233d5 100644
> --- a/drivers/common/cnxk/roc_dev.c
> +++ b/drivers/common/cnxk/roc_dev.c
> @@ -502,6 +502,8 @@ pf_vf_mbox_send_up_msg(struct dev *dev, void *rec_msg)
>         size_t size;
>
>         size = PLT_ALIGN(mbox_id2size(msg->hdr.id), MBOX_MSG_ALIGN);
> +       if (size < sizeof(struct mbox_msghdr))
> +               return;
>         /* Send UP message to all VF's */
>         for (vf = 0; vf < vf_mbox->ndevs; vf++) {
>                 /* VF active */
> diff --git a/drivers/common/cnxk/roc_nix_inl.c b/drivers/common/cnxk/roc_nix_inl.c
> index a205c658e9..7dbeae5017 100644
> --- a/drivers/common/cnxk/roc_nix_inl.c
> +++ b/drivers/common/cnxk/roc_nix_inl.c
> @@ -677,8 +677,7 @@ roc_nix_reassembly_configure(uint32_t max_wait_time, uint16_t max_frags)
>                 return -EFAULT;
>
>         PLT_SET_USED(max_frags);
> -       if (idev == NULL)
> -               return -ENOTSUP;
> +
>         roc_cpt = idev->cpt;
>         if (!roc_cpt) {
>                 plt_err("Cannot support inline inbound, cryptodev not probed");
> --
> 2.39.2
>
  

Patch

diff --git a/drivers/common/cnxk/roc_dev.c b/drivers/common/cnxk/roc_dev.c
index 084343c3b4..14aff233d5 100644
--- a/drivers/common/cnxk/roc_dev.c
+++ b/drivers/common/cnxk/roc_dev.c
@@ -502,6 +502,8 @@  pf_vf_mbox_send_up_msg(struct dev *dev, void *rec_msg)
 	size_t size;
 
 	size = PLT_ALIGN(mbox_id2size(msg->hdr.id), MBOX_MSG_ALIGN);
+	if (size < sizeof(struct mbox_msghdr))
+		return;
 	/* Send UP message to all VF's */
 	for (vf = 0; vf < vf_mbox->ndevs; vf++) {
 		/* VF active */
diff --git a/drivers/common/cnxk/roc_nix_inl.c b/drivers/common/cnxk/roc_nix_inl.c
index a205c658e9..7dbeae5017 100644
--- a/drivers/common/cnxk/roc_nix_inl.c
+++ b/drivers/common/cnxk/roc_nix_inl.c
@@ -677,8 +677,7 @@  roc_nix_reassembly_configure(uint32_t max_wait_time, uint16_t max_frags)
 		return -EFAULT;
 
 	PLT_SET_USED(max_frags);
-	if (idev == NULL)
-		return -ENOTSUP;
+
 	roc_cpt = idev->cpt;
 	if (!roc_cpt) {
 		plt_err("Cannot support inline inbound, cryptodev not probed");