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 1DA32A0548; Fri, 23 Apr 2021 10:11:01 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0575A4067E; Fri, 23 Apr 2021 10:11:01 +0200 (CEST) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by mails.dpdk.org (Postfix) with ESMTP id E09154014F for ; Fri, 23 Apr 2021 10:10:59 +0200 (CEST) Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4FRRkR2wQHz7wxL; Fri, 23 Apr 2021 16:08:31 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.498.0; Fri, 23 Apr 2021 16:10:54 +0800 From: "Min Hu (Connor)" To: CC: , , Date: Fri, 23 Apr 2021 16:11:04 +0800 Message-ID: <1619165464-7545-1-git-send-email-humin29@huawei.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH] mbuf: check mbuf dyn shared memory validity 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" From: Chengwen Feng Because mbuf dyn shared memory was allocated runtime, so it's necessary to check validity when dump mbuf dyn info. Also this patch adds an error logging when init shared memory fail. Fixes: 4958ca3a443a ("mbuf: support dynamic fields and flags") Cc: stable@dpdk.org Signed-off-by: Chengwen Feng Signed-off-by: Min Hu (Connor) --- lib/mbuf/rte_mbuf_dyn.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/mbuf/rte_mbuf_dyn.c b/lib/mbuf/rte_mbuf_dyn.c index 7d5e942..ca46eb2 100644 --- a/lib/mbuf/rte_mbuf_dyn.c +++ b/lib/mbuf/rte_mbuf_dyn.c @@ -115,8 +115,10 @@ init_shared_mem(void) } else { mz = rte_memzone_lookup(RTE_MBUF_DYN_MZNAME); } - if (mz == NULL) + if (mz == NULL) { + RTE_LOG(ERR, MBUF, "Failed to get mbuf dyn shared memory\n"); return -1; + } shm = mz->addr; @@ -525,7 +527,11 @@ void rte_mbuf_dyn_dump(FILE *out) size_t i; rte_mcfg_tailq_write_lock(); - init_shared_mem(); + if (init_shared_mem() < 0) { + rte_mcfg_tailq_write_unlock(); + return; + } + fprintf(out, "Reserved fields:\n"); mbuf_dynfield_list = RTE_TAILQ_CAST( mbuf_dynfield_tailq.head, mbuf_dynfield_list); -- 2.7.4