Variable total, which may be zero and result in segmentation fault.

This patch fixed it.

Fixes: 9b1249d9ff69 ("app/testpmd: support dumping socket memory")
Cc: sta...@dpdk.org

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

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 08da2b1..cde0a00 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -9631,6 +9631,9 @@ dump_socket_mem(FILE *f)
                        socket_stats.alloc_count,
                        socket_stats.free_count);
        }
+
+       if (total == 0)
+               return;
        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),
-- 
2.7.4

Reply via email to