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 thread. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
4244b320e7
commit
6b0242cfeb
1 changed files with 9 additions and 1 deletions
|
@ -2290,10 +2290,18 @@ struct net_buf *bt_conn_create_pdu(struct net_buf_pool *pool, size_t reserve)
|
|||
pool = &acl_tx_pool;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_DEBUG_CONN)) {
|
||||
if (IS_ENABLED(CONFIG_BT_DEBUG_CONN) ||
|
||||
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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue