From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id CE8201B1B0 for ; Mon, 8 Jan 2018 16:34:30 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jan 2018 07:34:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,330,1511856000"; d="scan'208";a="19225902" Received: from lgarcia5-mobl.amr.corp.intel.com (HELO kmorgan8-mobl3.amr.corp.intel.com) ([10.254.187.178]) by fmsmga004.fm.intel.com with ESMTP; 08 Jan 2018 07:34:29 -0800 From: Keith Wiles To: dev@dpdk.org Date: Mon, 8 Jan 2018 09:34:23 -0600 Message-Id: <20180108153423.57648-1-keith.wiles@intel.com> X-Mailer: git-send-email 2.10.1 Subject: [dpdk-dev] [PATCH] mbuf:using sanity checks do not panic on null mbuf X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jan 2018 15:34:31 -0000 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 --- lib/librte_mbuf/rte_mbuf.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index 7543662f7..58184c4f4 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 || !f) { + fprintf(stderr, "MBUF and/or FILE 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, " -- 2.14.1