From 0794b22c9c11070e3b36798ccebd7ff8b7b80d33 Mon Sep 17 00:00:00 2001 From: Jonathan Rico Date: Mon, 15 Apr 2024 15:06:30 +0200 Subject: [PATCH] Bluetooth: l2cap: Fix SDU buffer leak `ret` is the amount sent from the current buffer. `sent` contains the total amount that was transferred in the while loop. Signed-off-by: Jonathan Rico --- subsys/bluetooth/host/l2cap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/bluetooth/host/l2cap.c b/subsys/bluetooth/host/l2cap.c index e7b2f964eae..c266c553aca 100644 --- a/subsys/bluetooth/host/l2cap.c +++ b/subsys/bluetooth/host/l2cap.c @@ -2017,7 +2017,7 @@ static int l2cap_chan_le_send_sdu(struct bt_l2cap_le_chan *ch, sent += ret; /* If the current buffer has been fully consumed, destroy it */ - if (ret == rem_len) { + if (sent == rem_len) { net_buf_unref(buf); } }