Bluetooth: Audio: Add checks for bt_conn_ref return value where applicable
#95,148 建立於 2025年8月29日
描述
Summary
If the connection pointer supplied to an API call is not connected (e.g. if the application has cached it incorrectly), then when we perform a bt_conn_ref in the LE Audio code to take a reference, it can return NULL, which indicates a non-connected bt_conn pointer.
Describe the solution you'd like
For each call of bt_conn_ref in LE Audio from a struct bt_conn * from the higher layers, we need to verify that the return value is non-NULL.
Alternatives
Alternatively, we should check early in the function if the struct bt_conn is in the connected state. If a user attempts to perform any operation that expects the connection to be connected, and it is not, then we should return early to avoid unncessary memory copies etc. to generate the PDUs.
No response
Additional Context
This may also be an issue in other non-LE Audio places.