Skip to content

Commit d216dad

Browse files
jhedbergMirlenko
authored andcommitted
[nrf fromtree] Bluetooth: Host: Fix buffer allocation warnings in system workqueue
The buffer allocation in conn.c will trigger warnings if we try to use anything else than K_NO_WAIT for the timeout when called from within the system workqueue. The calls in l2cap.c and att.c which may pass non-zero timeouts already have proper handling for failed allocations, so make sure we use K_NO_WAIT to avoid unnecessary warnings from conn.c. Signed-off-by: Johan Hedberg <[email protected]> Signed-off-by: Aleksandr Mirlenko <[email protected]> (cherry picked from commit 05b16b9)
1 parent 71b0e2c commit d216dad

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

subsys/bluetooth/host/att.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,11 @@ static struct net_buf *bt_att_chan_create_pdu(struct bt_att_chan *chan, uint8_t
721721
timeout = BT_ATT_TIMEOUT;
722722
break;
723723
default:
724-
timeout = K_FOREVER;
724+
if (k_current_get() == k_work_queue_thread_get(&k_sys_work_q)) {
725+
timeout = K_NO_WAIT;
726+
} else {
727+
timeout = K_FOREVER;
728+
}
725729
}
726730

727731
/* This will reserve headspace for lower layers */

subsys/bluetooth/host/l2cap.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,11 @@ struct net_buf *bt_l2cap_create_pdu_timeout(struct net_buf_pool *pool,
674674
size_t reserve,
675675
k_timeout_t timeout)
676676
{
677+
if (!K_TIMEOUT_EQ(timeout, K_NO_WAIT) &&
678+
k_current_get() == k_work_queue_thread_get(&k_sys_work_q)) {
679+
timeout = K_NO_WAIT;
680+
}
681+
677682
return bt_conn_create_pdu_timeout(pool,
678683
sizeof(struct bt_l2cap_hdr) + reserve,
679684
timeout);

0 commit comments

Comments
 (0)