diff mbox series

mbuf: check mbuf dyn shared memory validity

Message ID 1619165464-7545-1-git-send-email-humin29@huawei.com (mailing list archive)
State Accepted
Delegated to: Thomas Monjalon
Headers show
Series mbuf: check mbuf dyn shared memory validity | expand

Checks

Context Check Description
ci/iol-mellanox-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-abi-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Min Hu (Connor) April 23, 2021, 8:11 a.m. UTC
From: Chengwen Feng <fengchengwen@huawei.com>

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 <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 lib/mbuf/rte_mbuf_dyn.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Olivier Matz April 28, 2021, 12:31 p.m. UTC | #1
Hi Chengwen,

On Fri, Apr 23, 2021 at 04:11:04PM +0800, Min Hu (Connor) wrote:
> From: Chengwen Feng <fengchengwen@huawei.com>
> 
> 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 <fengchengwen@huawei.com>
> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>

Acked-by: Olivier Matz <olivier.matz@6wind.com>
Thomas Monjalon May 4, 2021, 5:50 p.m. UTC | #2
28/04/2021 14:31, Olivier Matz:
> Hi Chengwen,
> 
> On Fri, Apr 23, 2021 at 04:11:04PM +0800, Min Hu (Connor) wrote:
> > From: Chengwen Feng <fengchengwen@huawei.com>
> > 
> > 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 <fengchengwen@huawei.com>
> > Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
> 
> Acked-by: Olivier Matz <olivier.matz@6wind.com>

With title "mbuf: check shared memory before dumping dynamic space",
applied, thanks.
diff mbox series

Patch

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);