Skip to content

Commit ad4bb37

Browse files
Vudentzjhedberg
authored andcommitted
Bluetooth: shell: Fix deadlock when receiving L2CAP packet
The TX and RX pool needs to be split otherwise the TX code path may consume all buffers causing the RX thread to deadlock which will possible deadlock the TX thread as well in case it needs more credits. Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent a1c74b7 commit ad4bb37

File tree

1 file changed

+4
-3
lines changed
  • tests/bluetooth/shell/src

1 file changed

+4
-3
lines changed

tests/bluetooth/shell/src/main.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ static bt_addr_le_t id_addr;
4848
static struct bt_conn *pairing_conn;
4949

5050
#if defined(CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL)
51-
NET_BUF_POOL_DEFINE(data_pool, 1, DATA_MTU, BT_BUF_USER_DATA_MIN, NULL);
51+
NET_BUF_POOL_DEFINE(data_tx_pool, 1, DATA_MTU, BT_BUF_USER_DATA_MIN, NULL);
52+
NET_BUF_POOL_DEFINE(data_rx_pool, 1, DATA_MTU, BT_BUF_USER_DATA_MIN, NULL);
5253
#endif
5354

5455
#if defined(CONFIG_BLUETOOTH_BREDR)
@@ -2055,7 +2056,7 @@ static struct net_buf *l2cap_alloc_buf(struct bt_l2cap_chan *chan)
20552056
{
20562057
printk("Channel %p requires buffer\n", chan);
20572058

2058-
return net_buf_alloc(&data_pool, K_FOREVER);
2059+
return net_buf_alloc(&data_rx_pool, K_FOREVER);
20592060
}
20602061

20612062
static struct bt_l2cap_chan_ops l2cap_ops = {
@@ -2172,7 +2173,7 @@ static int cmd_l2cap_send(int argc, char *argv[])
21722173
len = min(l2cap_chan.tx.mtu, DATA_MTU - BT_L2CAP_CHAN_SEND_RESERVE);
21732174

21742175
while (count--) {
2175-
buf = net_buf_alloc(&data_pool, K_FOREVER);
2176+
buf = net_buf_alloc(&data_tx_pool, K_FOREVER);
21762177
net_buf_reserve(buf, BT_L2CAP_CHAN_SEND_RESERVE);
21772178

21782179
net_buf_add_mem(buf, buf_data, len);

0 commit comments

Comments
 (0)