Skip to content

Commit aa6fd02

Browse files
jori-nordiccvinayak
authored andcommitted
Bluetooth: host: handle not getting a buffer
net_buf_alloc(K_FOREVER) can now fail (if run from the syswq). Propagate to the caller instead of asserting. Signed-off-by: Jonathan Rico <[email protected]> (cherry picked from commit aa30d07) Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent e2961ee commit aa6fd02

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

subsys/bluetooth/host/hci_core.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,12 @@ struct net_buf *bt_hci_cmd_create(uint16_t opcode, uint8_t param_len)
255255

256256
LOG_DBG("opcode 0x%04x param_len %u", opcode, param_len);
257257

258+
/* net_buf_alloc(K_FOREVER) can fail when run from the syswq */
258259
buf = net_buf_alloc(&hci_cmd_pool, K_FOREVER);
259-
__ASSERT_NO_MSG(buf);
260+
if (!buf) {
261+
LOG_DBG("Unable to allocate a command buffer");
262+
return NULL;
263+
}
260264

261265
LOG_DBG("buf %p", buf);
262266

0 commit comments

Comments
 (0)