From 195216d47106a534cfc30fa79c50a9a5f8aac3ee Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Sat, 11 Jun 2016 08:43:09 +0300 Subject: [PATCH] net: Convert net_buf_put() to use new nano_fifo_put_list() API This is the only safe way, especially when doing the call from a task. Change-Id: Ic50b73e04c4b831ac481dd56596f9d36cf0e2ccc Signed-off-by: Johan Hedberg --- net/buf.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/net/buf.c b/net/buf.c index b69942fbb91..f2825bf8ae4 100644 --- a/net/buf.c +++ b/net/buf.c @@ -106,22 +106,13 @@ struct net_buf *net_buf_get(struct nano_fifo *fifo, size_t reserve_head) void net_buf_put(struct nano_fifo *fifo, struct net_buf *buf) { - int mask; + struct net_buf *tail; - mask = irq_lock(); - - while (buf) { - struct net_buf *frag = buf->frags; - - if (frag) { - buf->flags |= NET_BUF_FRAGS; - } - - nano_fifo_put(fifo, buf); - buf = frag; + for (tail = buf; tail->frags; tail = tail->frags) { + tail->flags |= NET_BUF_FRAGS; } - irq_unlock(mask); + nano_fifo_put_list(fifo, buf, tail); } void net_buf_unref(struct net_buf *buf)