Skip to content

Commit

Permalink
app/testpmd: fix division by zero on socket memory dump
Browse files Browse the repository at this point in the history
[ upstream commit a767951 ]

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

This patch fixed it.

Fixes: 9b1249d ("app/testpmd: support dumping socket memory")

Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
  • Loading branch information
hushenggitcount authored and steevenlee committed Jun 8, 2021
1 parent 180a37c commit 6af34d2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/test-pmd/cmdline.c
Expand Up @@ -9557,7 +9557,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)
Expand Down

0 comments on commit 6af34d2

Please sign in to comment.