event/cnxk: fix out of bounds access

Message ID 20220424162455.1681020-1-gmuthukrishn@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: Jerin Jacob
Headers
Series event/cnxk: fix out of bounds access |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-abi-testing success Testing PASS

Commit Message

Gowrishankar Muthukrishnan April 24, 2022, 4:24 p.m. UTC
  Fix out of bounds array access reporrted in coverity scan.

Coverity issue: 375817
Fixes: 2351506401e ("event/cnxk: add SSO selftest and dump")

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 drivers/event/cnxk/cnxk_eventdev_selftest.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
  

Comments

Jerin Jacob May 14, 2022, 1:10 p.m. UTC | #1
On Sun, Apr 24, 2022 at 9:55 PM Gowrishankar Muthukrishnan
<gmuthukrishn@marvell.com> wrote:
>
> Fix out of bounds array access reporrted in coverity scan.

Fixed reported  typo

>
> Coverity issue: 375817
> Fixes: 2351506401e ("event/cnxk: add SSO selftest and dump")
>
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>

Acked-by: Jerin Jacob <jerinj@marvell.com>

Applied to dpdk-next-net-eventdev/for-main. Thanks

> ---
>  drivers/event/cnxk/cnxk_eventdev_selftest.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/drivers/event/cnxk/cnxk_eventdev_selftest.c b/drivers/event/cnxk/cnxk_eventdev_selftest.c
> index 2fe6467f88..3aa6f081a7 100644
> --- a/drivers/event/cnxk/cnxk_eventdev_selftest.c
> +++ b/drivers/event/cnxk/cnxk_eventdev_selftest.c
> @@ -626,6 +626,12 @@ launch_workers_and_wait(int (*main_thread)(void *),
>                 /* start core */ -1,
>                 /* skip main */ 1,
>                 /* wrap */ 0);
> +       if (w_lcore == RTE_MAX_LCORE) {
> +               plt_err("Failed to get next available lcore");
> +               free(param);
> +               return -1;
> +       }
> +
>         rte_eal_remote_launch(main_thread, &param[0], w_lcore);
>
>         for (port = 1; port < nb_workers; port++) {
> @@ -635,6 +641,12 @@ launch_workers_and_wait(int (*main_thread)(void *),
>                 param[port].dequeue_tmo_ticks = dequeue_tmo_ticks;
>                 rte_atomic_thread_fence(__ATOMIC_RELEASE);
>                 w_lcore = rte_get_next_lcore(w_lcore, 1, 0);
> +               if (w_lcore == RTE_MAX_LCORE) {
> +                       plt_err("Failed to get next available lcore");
> +                       free(param);
> +                       return -1;
> +               }
> +
>                 rte_eal_remote_launch(worker_thread, &param[port], w_lcore);
>         }
>
> --
> 2.25.1
>
  

Patch

diff --git a/drivers/event/cnxk/cnxk_eventdev_selftest.c b/drivers/event/cnxk/cnxk_eventdev_selftest.c
index 2fe6467f88..3aa6f081a7 100644
--- a/drivers/event/cnxk/cnxk_eventdev_selftest.c
+++ b/drivers/event/cnxk/cnxk_eventdev_selftest.c
@@ -626,6 +626,12 @@  launch_workers_and_wait(int (*main_thread)(void *),
 		/* start core */ -1,
 		/* skip main */ 1,
 		/* wrap */ 0);
+	if (w_lcore == RTE_MAX_LCORE) {
+		plt_err("Failed to get next available lcore");
+		free(param);
+		return -1;
+	}
+
 	rte_eal_remote_launch(main_thread, &param[0], w_lcore);
 
 	for (port = 1; port < nb_workers; port++) {
@@ -635,6 +641,12 @@  launch_workers_and_wait(int (*main_thread)(void *),
 		param[port].dequeue_tmo_ticks = dequeue_tmo_ticks;
 		rte_atomic_thread_fence(__ATOMIC_RELEASE);
 		w_lcore = rte_get_next_lcore(w_lcore, 1, 0);
+		if (w_lcore == RTE_MAX_LCORE) {
+			plt_err("Failed to get next available lcore");
+			free(param);
+			return -1;
+		}
+
 		rte_eal_remote_launch(worker_thread, &param[port], w_lcore);
 	}