[dpdk-dev] [PATCH 04/10] app/regex: fix division by zero
Ori Kam
orika at nvidia.com
Mon Apr 19 19:48:54 CEST 2021
Hi Min,
> -----Original Message-----
> From: Min Hu (Connor) <humin29 at huawei.com>
> Sent: Monday, April 19, 2021 4:35 PM
> Subject: [PATCH 04/10] app/regex: fix division by zero
>
> Variable nb_jobs, which may be zero, is used as a denominator.
>
> This patch fixed it.
>
> Fixes: f5cffb7eb7fb ("app/regex: read data file once at startup")
> Cc: stable at dpdk.org
>
> Signed-off-by: Min Hu (Connor) <humin29 at huawei.com>
> ---
> app/test-regex/main.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/app/test-regex/main.c b/app/test-regex/main.c
> index 8e665df..b49fa88 100644
> --- a/app/test-regex/main.c
> +++ b/app/test-regex/main.c
> @@ -725,9 +725,11 @@ main(int argc, char **argv)
> if (data_len <= 0)
> rte_exit(EXIT_FAILURE, "Error, can't read file, or file is
> empty.\n");
>
> - job_len = data_len / nb_jobs;
> - if (job_len == 0)
> - rte_exit(EXIT_FAILURE, "Error, To many jobs, for the given
> input.\n");
> + if (!nb_jobs) {
> + job_len = data_len / nb_jobs;
> + if (job_len == 0)
> + rte_exit(EXIT_FAILURE, "Error, To many jobs, for the
> given input.\n");
> + }
>
> if (job_len > nb_max_payload)
> rte_exit(EXIT_FAILURE, "Error, not enough jobs to cover
> input.\n");
> --
> 2.7.4
Acked-by: Ori Kam <orika at nvidia.com>
Thanks,
Ori
More information about the dev
mailing list