summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2016-10-21 16:11:36 +0300
committerAnas Nashif <nashif@linux.intel.com>2016-10-26 12:48:47 +0000
commit76240677d95b88ffe1f3f19f5b4d76adca7d394f (patch)
tree3408d718bcbcbe221df77396e6fad364cf4e9532 /net
parentb86d19d1bd7fd8430379dcb99a6ef43d948272ef (diff)
net: buf: Make net_buf_frag_add take ownership of the buffer
This simplify buffer handling so that no extra references are needed. Change-Id: Id99a0a75b39ca8db2216668f76c5a672713075ae Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/l2cap.c3
-rw-r--r--net/buf.c3
2 files changed, 2 insertions, 4 deletions
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index 383782bcf..c81ec8512 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -999,9 +999,6 @@ static struct net_buf *l2cap_alloc_frag(struct bt_l2cap_le_chan *chan)
net_buf_frag_add(chan->_sdu, frag);
- /* Drop own reference since net_buf_frag_add adds a reference */
- net_buf_unref(frag);
-
return frag;
}
diff --git a/net/buf.c b/net/buf.c
index b143017ba..8ad72a54f 100644
--- a/net/buf.c
+++ b/net/buf.c
@@ -187,7 +187,8 @@ void net_buf_frag_insert(struct net_buf *parent, struct net_buf *frag)
if (parent->frags) {
net_buf_frag_last(frag)->frags = parent->frags;
}
- parent->frags = net_buf_ref(frag);
+ /* Take ownership of the fragment reference */
+ parent->frags = frag;
}
struct net_buf *net_buf_frag_add(struct net_buf *head, struct net_buf *frag)