From: "Min Hu (Connor)" <humin29@huawei.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@intel.com>, <olivier.matz@6wind.com>,
<thomas@monjalon.net>
Subject: [dpdk-dev] [PATCH] mbuf: check mbuf dyn shared memory validity
Date: Fri, 23 Apr 2021 16:11:04 +0800 [thread overview]
Message-ID: <1619165464-7545-1-git-send-email-humin29@huawei.com> (raw)
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(-)
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
next reply other threads:[~2021-04-23 8:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-23 8:11 Min Hu (Connor) [this message]
2021-04-28 12:31 ` Olivier Matz
2021-05-04 17:50 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1619165464-7545-1-git-send-email-humin29@huawei.com \
--to=humin29@huawei.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=olivier.matz@6wind.com \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).