Skip to content
Browse files

Bluetooth: Fix deadlock caused by blocking on syswq

Since TX complete notification are dispatched with syswq blocking on it
can completely deadlock Bluetooth so this attempt to make it safe by
return -ENOMEM if that the current thread happens to be the syswq

Signed-off-by: Luiz Augusto von Dentz <>
  • Loading branch information...
Vudentz authored and carlescufi committed Aug 1, 2019
1 parent 4244b32 commit 6b0242cfeb5cf8275187062d24910683ddaf9486
Showing with 9 additions and 1 deletion.
  1. +9 −1 subsys/bluetooth/host/conn.c
@@ -2290,10 +2290,18 @@ struct net_buf *bt_conn_create_pdu(struct net_buf_pool *pool, size_t reserve)
pool = &acl_tx_pool;

k_current_get() == &k_sys_work_q.thread) {
buf = net_buf_alloc(pool, K_NO_WAIT);
if (!buf) {
BT_WARN("Unable to allocate buffer");
/* Cannot block with K_FOREVER on k_sys_work_q as that
* can cause a deadlock when trying to dispatch TX
* notification.
if (k_current_get() == &k_sys_work_q.thread) {
return NULL;
buf = net_buf_alloc(pool, K_FOREVER);
} else {

0 comments on commit 6b0242c

Please sign in to comment.
You can’t perform that action at this time.