Skip to content

Commit 16bad38

Browse files
committed
net_buf: buf: return on double free
If assertions are disabled, return on double free instead of wrapping around the reference count. Signed-off-by: Jordan Yates <[email protected]>
1 parent 29b167b commit 16bad38

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/net_buf/buf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,13 +448,13 @@ void net_buf_unref(struct net_buf *buf)
448448
struct net_buf_pool *pool;
449449

450450
__ASSERT(buf->ref, "buf %p double free", buf);
451-
#if defined(CONFIG_NET_BUF_LOG)
452451
if (!buf->ref) {
452+
#if defined(CONFIG_NET_BUF_LOG)
453453
NET_BUF_ERR("%s():%d: buf %p double free", func, line,
454454
buf);
455+
#endif
455456
return;
456457
}
457-
#endif
458458
NET_BUF_DBG("buf %p ref %u pool_id %u frags %p", buf, buf->ref,
459459
buf->pool_id, buf->frags);
460460

0 commit comments

Comments
 (0)