Skip to content

Commit 99066db

Browse files
Vudentzjhedberg
authored andcommitted
Bluetooth: L2CAP: Ignore packets received while disconnecting
Drop packets received while disconnecting since they would most likely be flushed once peer respond there is no gain in keeping them on a queue. Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 5d26693 commit 99066db

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

subsys/bluetooth/host/l2cap.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,6 +1693,19 @@ static void l2cap_chan_le_recv(struct bt_l2cap_le_chan *chan,
16931693

16941694
l2cap_chan_send_credits(chan, buf, 1);
16951695
}
1696+
1697+
static void l2cap_chan_recv_queue(struct bt_l2cap_le_chan *chan,
1698+
struct net_buf *buf)
1699+
{
1700+
if (chan->chan.state == BT_L2CAP_DISCONNECT) {
1701+
BT_WARN("Ignoring data received while disconnecting");
1702+
net_buf_unref(buf);
1703+
return;
1704+
}
1705+
1706+
net_buf_put(&chan->rx_queue, buf);
1707+
k_work_submit(&chan->rx_work);
1708+
}
16961709
#endif /* CONFIG_BT_L2CAP_DYNAMIC_CHANNEL */
16971710

16981711
static void l2cap_chan_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
@@ -1701,8 +1714,7 @@ static void l2cap_chan_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
17011714
struct bt_l2cap_le_chan *ch = BT_L2CAP_LE_CHAN(chan);
17021715

17031716
if (L2CAP_LE_CID_IS_DYN(ch->rx.cid)) {
1704-
net_buf_put(&ch->rx_queue, net_buf_ref(buf));
1705-
k_work_submit(&ch->rx_work);
1717+
l2cap_chan_recv_queue(ch, buf);
17061718
return;
17071719
}
17081720
#endif /* CONFIG_BT_L2CAP_DYNAMIC_CHANNEL */

0 commit comments

Comments
 (0)