From ad4bb37b179b07ac85d19e599eaa0a0b5a875dec Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Wed, 3 May 2017 14:26:30 +0300 Subject: [PATCH] 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 --- tests/bluetooth/shell/src/main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/bluetooth/shell/src/main.c b/tests/bluetooth/shell/src/main.c index 68dc2b26590..ede44a0f007 100644 --- a/tests/bluetooth/shell/src/main.c +++ b/tests/bluetooth/shell/src/main.c @@ -48,7 +48,8 @@ static bt_addr_le_t id_addr; static struct bt_conn *pairing_conn; #if defined(CONFIG_BLUETOOTH_L2CAP_DYNAMIC_CHANNEL) -NET_BUF_POOL_DEFINE(data_pool, 1, DATA_MTU, BT_BUF_USER_DATA_MIN, NULL); +NET_BUF_POOL_DEFINE(data_tx_pool, 1, DATA_MTU, BT_BUF_USER_DATA_MIN, NULL); +NET_BUF_POOL_DEFINE(data_rx_pool, 1, DATA_MTU, BT_BUF_USER_DATA_MIN, NULL); #endif #if defined(CONFIG_BLUETOOTH_BREDR) @@ -2055,7 +2056,7 @@ static struct net_buf *l2cap_alloc_buf(struct bt_l2cap_chan *chan) { printk("Channel %p requires buffer\n", chan); - return net_buf_alloc(&data_pool, K_FOREVER); + return net_buf_alloc(&data_rx_pool, K_FOREVER); } static struct bt_l2cap_chan_ops l2cap_ops = { @@ -2172,7 +2173,7 @@ static int cmd_l2cap_send(int argc, char *argv[]) len = min(l2cap_chan.tx.mtu, DATA_MTU - BT_L2CAP_CHAN_SEND_RESERVE); while (count--) { - buf = net_buf_alloc(&data_pool, K_FOREVER); + buf = net_buf_alloc(&data_tx_pool, K_FOREVER); net_buf_reserve(buf, BT_L2CAP_CHAN_SEND_RESERVE); net_buf_add_mem(buf, buf_data, len);