app/regex: avoid division by zero

Message ID 20210524085700.15534-1-thierry.herbelot@6wind.com (mailing list archive)
State Accepted, archived
Headers
Series app/regex: avoid division by zero |

Checks

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

Commit Message

Thierry Herbelot May 24, 2021, 8:57 a.m. UTC
  Check that nb_jobs is not zero before using it for a division.

Fixes: f5cffb7eb7fb6 ("app/regex: read data file once at startup")
Cc: stable@dpdk.org
Cc: Ori Kam <orika@nvidia.com>

Signed-off-by: Thierry Herbelot <thierry.herbelot@6wind.com>
---
 app/test-regex/main.c | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

humin (Q) May 24, 2021, 12:09 p.m. UTC | #1
Hi, Thierry,
	This bug has been fixed in my earlier patch, please refer to:
https://patches.dpdk.org/project/dpdk/patch/1618839289-33224-5-git-send-email-humin29@huawei.com/

	Thanks.


在 2021/5/24 16:57, Thierry Herbelot 写道:
> Check that nb_jobs is not zero before using it for a division.
> 
> Fixes: f5cffb7eb7fb6 ("app/regex: read data file once at startup")
> Cc: stable@dpdk.org
> Cc: Ori Kam <orika@nvidia.com>
> 
> Signed-off-by: Thierry Herbelot <thierry.herbelot@6wind.com>
> ---
>   app/test-regex/main.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/app/test-regex/main.c b/app/test-regex/main.c
> index 8e665df73ce0..8f48cab11924 100644
> --- a/app/test-regex/main.c
> +++ b/app/test-regex/main.c
> @@ -714,6 +714,8 @@ main(int argc, char **argv)
>   		rte_exit(EXIT_FAILURE, "Number of QPs must be greater than 0\n");
>   	if (nb_lcores == 0)
>   		rte_exit(EXIT_FAILURE, "Number of lcores must be greater than 0\n");
> +	if (nb_jobs == 0)
> +		rte_exit(EXIT_FAILURE, "Number of jobs must be greater than 0\n");
>   	if (distribute_qps_to_lcores(nb_lcores, nb_qps, &qps_per_lcore) < 0)
>   		rte_exit(EXIT_FAILURE, "Failed to distribute queues to lcores!\n");
>   	ret = init_port(&nb_max_payload, rules_file,
>
  
Thomas Monjalon June 26, 2022, 5:41 p.m. UTC | #2
24/05/2021 14:09, Min Hu (Connor):
> Hi, Thierry,
> 	This bug has been fixed in my earlier patch, please refer to:
> https://patches.dpdk.org/project/dpdk/patch/1618839289-33224-5-git-send-email-humin29@huawei.com/

Your patch is doing
+       if (!nb_jobs) {
+               job_len = data_len / nb_jobs;

It looks wrong.
I am for taking Thierry's patch.

> 在 2021/5/24 16:57, Thierry Herbelot 写道:
> > Check that nb_jobs is not zero before using it for a division.
> > 
> > Fixes: f5cffb7eb7fb6 ("app/regex: read data file once at startup")
> > Cc: stable@dpdk.org
> > Cc: Ori Kam <orika@nvidia.com>
> > 
> > Signed-off-by: Thierry Herbelot <thierry.herbelot@6wind.com>
> > ---
> >   app/test-regex/main.c | 2 ++
> >   1 file changed, 2 insertions(+)
> > 
> > diff --git a/app/test-regex/main.c b/app/test-regex/main.c
> > index 8e665df73ce0..8f48cab11924 100644
> > --- a/app/test-regex/main.c
> > +++ b/app/test-regex/main.c
> > @@ -714,6 +714,8 @@ main(int argc, char **argv)
> >   		rte_exit(EXIT_FAILURE, "Number of QPs must be greater than 0\n");
> >   	if (nb_lcores == 0)
> >   		rte_exit(EXIT_FAILURE, "Number of lcores must be greater than 0\n");
> > +	if (nb_jobs == 0)
> > +		rte_exit(EXIT_FAILURE, "Number of jobs must be greater than 0\n");
> >   	if (distribute_qps_to_lcores(nb_lcores, nb_qps, &qps_per_lcore) < 0)
> >   		rte_exit(EXIT_FAILURE, "Failed to distribute queues to lcores!\n");
> >   	ret = init_port(&nb_max_payload, rules_file,
  
Thomas Monjalon July 5, 2022, 8:16 p.m. UTC | #3
24/05/2021 10:57, Thierry Herbelot:
> Check that nb_jobs is not zero before using it for a division.
> 
> Fixes: f5cffb7eb7fb6 ("app/regex: read data file once at startup")
> Cc: stable@dpdk.org
> Cc: Ori Kam <orika@nvidia.com>
> 
> Signed-off-by: Thierry Herbelot <thierry.herbelot@6wind.com>

Missing ack, but applied after a long wait, sorry.
  

Patch

diff --git a/app/test-regex/main.c b/app/test-regex/main.c
index 8e665df73ce0..8f48cab11924 100644
--- a/app/test-regex/main.c
+++ b/app/test-regex/main.c
@@ -714,6 +714,8 @@  main(int argc, char **argv)
 		rte_exit(EXIT_FAILURE, "Number of QPs must be greater than 0\n");
 	if (nb_lcores == 0)
 		rte_exit(EXIT_FAILURE, "Number of lcores must be greater than 0\n");
+	if (nb_jobs == 0)
+		rte_exit(EXIT_FAILURE, "Number of jobs must be greater than 0\n");
 	if (distribute_qps_to_lcores(nb_lcores, nb_qps, &qps_per_lcore) < 0)
 		rte_exit(EXIT_FAILURE, "Failed to distribute queues to lcores!\n");
 	ret = init_port(&nb_max_payload, rules_file,