zephyrproject-rtos/zephyr

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

已关闭

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

 (1 条评论) (0 个反应) (2 位负责人)C (9,144 个派生)batch import
EnhancementGood first issuearea: Bluetootharea: Bluetooth Audio

仓库指标

星标
 (15,249 个星标)
PR 合并指标
 (平均合并 4天 21小时) (30 天内合并 1,000 个 PR)

描述

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.

贡献者指南