Skip to contentSkip to conversation

mbuf: check mbuf dyn shared memory validity

PATCH In review Min Hu (Connor) 3 participants 3 messages Apr 23, 2021 – May 4, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mbuf: check mbuf dyn shared memory validity

From: Chengwen Feng <[email protected]>

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")
---
 lib/mbuf/rte_mbuf_dyn.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
lib/mbuf/rte_mbuf_dyn.c +8 -2
index 7d5e942..ca46eb2 100644
@@ -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);
Signature · 1 line
2.7.4
Acked-by on v1 1/1
#1 lore raw

Hi Chengwen,

Quoted 5 lines · Min Hu (Connor)

From: Chengwen Feng <[email protected]>

Because mbuf dyn shared memory was allocated runtime, so it's necessary to check validity when dump mbuf dyn info.

Quoted 7 lines

Also this patch adds an error logging when init shared memory fail.

Fixes 4958ca3a443a ("mbuf: support dynamic fields and flags")
#2 lore raw

28/04/2021 14:31, Olivier Matz:

Quoted 10 lines

Hi Chengwen,

Quoted 7 lines · Min Hu (Connor)

From: Chengwen Feng <[email protected]>

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.

Quoted 7 lines
Quoted 5 lines
Fixes 4958ca3a443a ("mbuf: support dynamic fields and flags")

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