net: Do not remove fragments if main buffer is not removed

The fix prevents the net_nbuf_unref() from removing fragment
list if the top level net_buf is not removed.

Change-Id: Ice580c25bd74f3239c01321f2b9d61cc8c0c9c1d
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2016-05-23 17:33:14 +03:00
commit 9d0de92f59

View file

@ -542,10 +542,11 @@ void net_nbuf_unref(struct net_buf *buf)
} }
/* Remove the fragment list elements first, otherwise we /* Remove the fragment list elements first, otherwise we
* have a memory leak. * have a memory leak. But only if we are to be remove the
* buffer.
*/ */
frag = buf->frags; frag = buf->frags;
while (frag) { while (!(buf->ref - 1) && frag) {
struct net_buf *next = frag->frags; struct net_buf *next = frag->frags;
net_buf_frag_del(buf, frag); net_buf_frag_del(buf, frag);