[dpdk-dev] [PATCH 04/10] app/regex: fix division by zero

Min Hu (Connor) humin29 at huawei.com
Mon Apr 19 15:34:43 CEST 2021


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



More information about the dev mailing list