Variable i is used as a denominator which may be zero, and
this may result in segmentation fault.

This patch fixed it.

Fixes: 948bc3d6d095 ("test: add reciprocal based division")
Cc: sta...@dpdk.org

Signed-off-by: Min Hu (Connor) <humi...@huawei.com>
---
 app/test/test_reciprocal_division_perf.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/app/test/test_reciprocal_division_perf.c 
b/app/test/test_reciprocal_division_perf.c
index a7be8aa..2647308 100644
--- a/app/test/test_reciprocal_division_perf.c
+++ b/app/test/test_reciprocal_division_perf.c
@@ -143,7 +143,7 @@ test_reciprocal_division_perf(void)
                                        "result %"PRIu64"",
                                        nresult_u64, rresult_u64);
                        result = 1;
-                       break;
+                       goto err;
                }
        }
 
@@ -182,7 +182,7 @@ test_reciprocal_division_perf(void)
                                        dividend_u64, divisor_u64,
                                        nresult_u64, rresult_u64);
                        result = 1;
-                       break;
+                       goto err;
                }
        }
        printf("64bit Division results:\n");
@@ -195,6 +195,7 @@ test_reciprocal_division_perf(void)
        printf("Cycles per division(reciprocal) : %3.2f\n",
                        ((double)tot_cyc_r)/i);
 
+err:
        return result;
 }
 
-- 
2.7.4

Reply via email to