From: Min Hu (Connor) Date: Mon, 26 Apr 2021 11:57:57 +0000 (+0800) Subject: app/testpmd: fix division by zero on socket memory dump X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=a767951e597964e6c02529097edd2b43b5aace4d;p=dpdk.git app/testpmd: fix division by zero on socket memory dump Variable total, which may be zero and result in segmentation fault. This patch fixed it. Fixes: 9b1249d9ff69 ("app/testpmd: support dumping socket memory") Cc: stable@dpdk.org Signed-off-by: Min Hu (Connor) Reviewed-by: Ferruh Yigit --- diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 5fdcc1ca18..29ee41da5f 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -9731,7 +9731,7 @@ dump_socket_mem(FILE *f) fprintf(f, "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n", (double)total / (1024 * 1024), (double)alloc / (1024 * 1024), - (double)alloc * 100 / (double)total, + total ? ((double)alloc * 100 / (double)total) : 0, (double)free / (1024 * 1024), n_alloc, n_free); if (last_allocs)