[dpdk-dev,v3] mbuf: fix freeing of NULL mbuf when debug enabled

Message ID 20180129093923.18588-1-olivier.matz@6wind.com (mailing list archive)
State Accepted, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Olivier Matz Jan. 29, 2018, 9:39 a.m. UTC
  Do not panic when calling rte_pktmbuf_free(NULL) with mbuf debug
enabled, it is a valid operation.

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org

Reported-by: Keith Wiles <keith.wiles@intel.com>
Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 lib/librte_mbuf/rte_mbuf.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
  

Comments

Thomas Monjalon Jan. 29, 2018, 3:58 p.m. UTC | #1
29/01/2018 10:39, Olivier Matz:
> Do not panic when calling rte_pktmbuf_free(NULL) with mbuf debug
> enabled, it is a valid operation.
> 
> Fixes: af75078fece3 ("first public release")
> Cc: stable@dpdk.org
> 
> Reported-by: Keith Wiles <keith.wiles@intel.com>
> Signed-off-by: Olivier Matz <olivier.matz@6wind.com>

Applied, thanks
  

Patch

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 4519fb303..719d04dda 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -1439,13 +1439,14 @@  rte_pktmbuf_free_seg(struct rte_mbuf *m)
  * segment is added back into its original mempool.
  *
  * @param m
- *   The packet mbuf to be freed.
+ *   The packet mbuf to be freed. If NULL, the function does nothing.
  */
 static inline void rte_pktmbuf_free(struct rte_mbuf *m)
 {
 	struct rte_mbuf *m_next;
 
-	__rte_mbuf_sanity_check(m, 1);
+	if (m != NULL)
+		__rte_mbuf_sanity_check(m, 1);
 
 	while (m != NULL) {
 		m_next = m->next;