From: Keith Wiles <keith.wiles@intel.com>
To: dev@dpdk.org
Cc: stephen@networkplumber.org, jerin.jacob@caviumnetworks.com
Subject: [dpdk-dev] [PATCH v2] mbuf:using sanity checks do not panic on null mbuf
Date: Tue, 9 Jan 2018 08:29:28 -0600 [thread overview]
Message-ID: <20180109142928.81687-1-keith.wiles@intel.com> (raw)
In-Reply-To: <20180108153423.57648-1-keith.wiles@intel.com>
The rte_pktmbuf_free() allows for NULL mbuf pointer, but
when sanity check is enabled it will panic with null pointer.
Signed-off-by: Keith Wiles <keith.wiles@intel.com>
---
lib/librte_mbuf/rte_mbuf.c | 10 ++++++++--
test/test/test_mbuf.c | 4 +---
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 7543662f7..621679c92 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -205,8 +205,9 @@ rte_mbuf_sanity_check(const struct rte_mbuf *m, int is_header)
const struct rte_mbuf *m_seg;
unsigned int nb_segs;
- if (m == NULL)
- rte_panic("mbuf is NULL\n");
+ /* Calling with NULL is valid in the API */
+ if (!m)
+ return;
/* generic checks */
if (m->pool == NULL)
@@ -243,6 +244,11 @@ rte_pktmbuf_dump(FILE *f, const struct rte_mbuf *m, unsigned dump_len)
__rte_mbuf_sanity_check(m, 1);
+ if (!m) {
+ fprintf(stderr, "MBUF pointer is NULL\n");
+ return;
+ }
+
fprintf(f, "dump mbuf at %p, iova=%"PRIx64", buf_len=%u\n",
m, (uint64_t)m->buf_iova, (unsigned)m->buf_len);
fprintf(f, " pkt_len=%"PRIu32", ol_flags=%"PRIx64", nb_segs=%u, "
diff --git a/test/test/test_mbuf.c b/test/test/test_mbuf.c
index 9e82a20be..146eaf0e5 100644
--- a/test/test/test_mbuf.c
+++ b/test/test/test_mbuf.c
@@ -864,10 +864,8 @@ test_failing_mbuf_sanity_check(struct rte_mempool *pktmbuf_pool)
printf("Now checking for error conditions\n");
- if (verify_mbuf_check_panics(NULL)) {
- printf("Error with NULL mbuf test\n");
+ if (verify_mbuf_check_panics(NULL) != -1)
return -1;
- }
badbuf = *buf;
badbuf.pool = NULL;
--
2.14.1
next prev parent reply other threads:[~2018-01-09 14:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-08 15:34 [dpdk-dev] [PATCH] " Keith Wiles
2018-01-08 15:39 ` Stephen Hemminger
2018-01-08 15:41 ` Wiles, Keith
2018-01-09 4:39 ` Jerin Jacob
2018-01-09 14:29 ` Keith Wiles [this message]
2018-01-16 14:04 ` [dpdk-dev] [PATCH v2] " Olivier Matz
2018-01-16 14:19 ` Wiles, Keith
2018-01-29 9:39 ` [dpdk-dev] [PATCH v3] mbuf: fix freeing of NULL mbuf when debug enabled Olivier Matz
2018-01-29 15:58 ` 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=20180109142928.81687-1-keith.wiles@intel.com \
--to=keith.wiles@intel.com \
--cc=dev@dpdk.org \
--cc=jerin.jacob@caviumnetworks.com \
--cc=stephen@networkplumber.org \
/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).