Skip to content

Commit 6c56f04

Browse files
committed
Bluetoth: Host: ATT: 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 bt_att_chan_create_pdu() already has handling for failed allocations so this shouldn't cause any adverse effects. Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
1 parent a94acf3 commit 6c56f04

File tree

1 file changed

+13
-8
lines changed
  • subsys/bluetooth/host

1 file changed

+13
-8
lines changed

subsys/bluetooth/host/att.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -723,14 +723,19 @@ static struct net_buf *bt_att_chan_create_pdu(struct bt_att_chan *chan, uint8_t
723723
return NULL;
724724
}
725725

726-
switch (att_op_get_type(op)) {
727-
case ATT_RESPONSE:
728-
case ATT_CONFIRMATION:
729-
/* Use a timeout only when responding/confirming */
730-
timeout = BT_ATT_TIMEOUT;
731-
break;
732-
default:
733-
timeout = K_FOREVER;
726+
/* We can't block in the system workqueue */
727+
if (k_current_get() == k_work_queue_thread_get(&k_sys_work_q)) {
728+
timeout = K_NO_WAIT;
729+
} else {
730+
switch (att_op_get_type(op)) {
731+
case ATT_RESPONSE:
732+
case ATT_CONFIRMATION:
733+
/* Use a timeout only when responding/confirming */
734+
timeout = BT_ATT_TIMEOUT;
735+
break;
736+
default:
737+
timeout = K_FOREVER;
738+
}
734739
}
735740

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

0 commit comments

Comments
 (0)