Skip to content

Commit 1c8fe67

Browse files
jori-nordiccarlescufi
authored andcommitted
Bluetooth: host: l2cap: release segment in all cases
See code comment Signed-off-by: Jonathan Rico <[email protected]>
1 parent 7a6872d commit 1c8fe67

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

subsys/bluetooth/host/l2cap.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,12 +1971,12 @@ static int l2cap_chan_le_send(struct bt_l2cap_le_chan *ch,
19711971
BT_WARN("Unable to send seg %d", err);
19721972
atomic_inc(&ch->tx.credits);
19731973

1974-
/* If the segment is not the original buffer release it since it
1975-
* won't be needed anymore.
1974+
/* The host takes ownership of the reference in seg when
1975+
* bt_l2cap_send_cb is successful. The call returned an error,
1976+
* so we must get rid of the reference that was taken in
1977+
* l2cap_chan_create_seg.
19761978
*/
1977-
if (seg != buf) {
1978-
net_buf_unref(seg);
1979-
}
1979+
net_buf_unref(seg);
19801980

19811981
if (err == -ENOBUFS) {
19821982
/* Restore state since segment could not be sent */

0 commit comments

Comments
 (0)