From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EDE93A0548; Mon, 26 Apr 2021 13:58:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D896C41110; Mon, 26 Apr 2021 13:58:29 +0200 (CEST) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by mails.dpdk.org (Postfix) with ESMTP id 6E01240140 for ; Mon, 26 Apr 2021 13:58:28 +0200 (CEST) Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4FTNdV2SM3zBsJR for ; Mon, 26 Apr 2021 19:55:58 +0800 (CST) Received: from [10.67.103.128] (10.67.103.128) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.498.0; Mon, 26 Apr 2021 19:58:22 +0800 From: "Min Hu (Connor)" To: CC: , References: <1619005102-38437-1-git-send-email-humin29@huawei.com> Message-ID: Date: Mon, 26 Apr 2021 19:58:22 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: <1619005102-38437-1-git-send-email-humin29@huawei.com> Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.103.128] X-CFilter-Loop: Reflected Subject: Re: [dpdk-dev] [PATCH] app/testpmd: fix division by zero bug X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" ÔÚ 2021/4/21 19:38, Min Hu (Connor) дµÀ: > 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) > --- > 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), > Agreed, fixed in v2, thanks.