Skip to content

Commit ebd8ab1

Browse files
jhedbergcvinayak
authored andcommitted
Bluetoth: 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]> (cherry picked from commit 05b16b9) Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 15d753d commit ebd8ab1

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
@@ -671,7 +671,11 @@ static struct net_buf *bt_att_chan_create_pdu(struct bt_att_chan *chan, uint8_t
671671
timeout = BT_ATT_TIMEOUT;
672672
break;
673673
default:
674-
timeout = K_FOREVER;
674+
if (k_current_get() == k_work_queue_thread_get(&k_sys_work_q)) {
675+
timeout = K_NO_WAIT;
676+
} else {
677+
timeout = K_FOREVER;
678+
}
675679
}
676680

677681
buf = bt_l2cap_create_pdu_timeout(NULL, 0, timeout);

subsys/bluetooth/host/l2cap.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,11 @@ struct net_buf *bt_l2cap_create_pdu_timeout(struct net_buf_pool *pool,
656656
size_t reserve,
657657
k_timeout_t timeout)
658658
{
659+
if (!K_TIMEOUT_EQ(timeout, K_NO_WAIT) &&
660+
k_current_get() == k_work_queue_thread_get(&k_sys_work_q)) {
661+
timeout = K_NO_WAIT;
662+
}
663+
659664
return bt_conn_create_pdu_timeout(pool,
660665
sizeof(struct bt_l2cap_hdr) + reserve,
661666
timeout);

0 commit comments

Comments
 (0)