zephyrproject-rtos/zephyr

Bluetooth: Audio: Add checks for bt_conn_ref return value where applicable

Open

#95,148 创建于 2025年8月29日

在 GitHub 查看
 (1 评论) (0 反应) (2 负责人)C (15,249 star) (9,144 fork)batch import
EnhancementGood first issuearea: Bluetootharea: Bluetooth Audio

描述

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.

贡献者指南