Skip to content

Commit

Permalink
mbuf: check shared memory before dumping dynamic space
Browse files Browse the repository at this point in the history
[ upstream commit d4902ed ]

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: 4958ca3 ("mbuf: support dynamic fields and flags")

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>
  • Loading branch information
fengchengwen authored and steevenlee committed Jun 8, 2021
1 parent 5f90abb commit f532cbb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/librte_mbuf/rte_mbuf_dyn.c
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f532cbb

Please sign in to comment.