mbuf: fix freeing of NULL mbuf when debug enabled
authorOlivier Matz <olivier.matz@6wind.com>
Fri, 26 Jan 2018 08:40:55 +0000 (09:40 +0100)
committerOlivier Matz <olivier.matz@6wind.com>
Fri, 26 Jan 2018 10:22:57 +0000 (11:22 +0100)
Do not panic when calling rte_pktmbuf_free(NULL) with mbuf debug
enabled, it is a valid operation.

Reported-by: Keith Wiles <keith.wiles@intel.com>
Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
lib/librte_mbuf/rte_mbuf.h

index 4519fb3..719d04d 100644 (file)
@@ -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;