Skip to content
Commit 30098c88 authored by Aleksander Wasaznik's avatar Aleksander Wasaznik Committed by Carles Cufí
Browse files

Bluetooth: Host: Detect deadlock in bt_att_req_alloc

`gatt_req_alloc` will wait until a `req` is free (or until timeout).
`req`s are freed on the BT RX thread in calls into bt_att_recv.

When `gatt_req_alloc` called on the BT RX thread itself when there are
no free `req`s, it will block the BT RX thread and deadlock. The
deadlock lasts until timeout.

This change detects this condition and returns the failure early.

Fixes https://github.com/zephyrproject-rtos/zephyr/issues/39624

 where
if `bt_gatt_write` is called from BT RX thread (as can happen if it is
called from a bluetooth callback), the BT RX thread can be blocked and
prevented from processing the request responses and unblocking itself.
This was the cause of a soft 30s deadlock until gatt_req_alloc timeouts.

Signed-off-by: default avatarAleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
parent 8d5be19e
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment