Skip to content

Commit 29b167b

Browse files
committed
net_buf: buf: assert on double free
Unreferencing a buffer that has already been freed should trigger an assertion as it indicates a critical logic error and potential security concern. Signed-off-by: Jordan Yates <[email protected]>
1 parent 43fe3a2 commit 29b167b

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lib/net_buf/buf.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ void net_buf_unref(struct net_buf *buf)
447447
struct net_buf *frags = buf->frags;
448448
struct net_buf_pool *pool;
449449

450+
__ASSERT(buf->ref, "buf %p double free", buf);
450451
#if defined(CONFIG_NET_BUF_LOG)
451452
if (!buf->ref) {
452453
NET_BUF_ERR("%s():%d: buf %p double free", func, line,

0 commit comments

Comments
 (0)