Bluetooth: Host: Add "assert non-null" to bt_conn_ref

Clearly `conn` must be non-null since it's dereferenced without checks.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
This commit is contained in:
Aleksander Wasaznik 2022-09-19 10:58:13 +02:00 committed by Fabio Baltieri
parent a8f12ab690
commit 7e11b98125

View file

@ -1120,6 +1120,8 @@ struct bt_conn *bt_conn_ref(struct bt_conn *conn)
{
atomic_val_t old;
__ASSERT_NO_MSG(conn);
/* Reference counter must be checked to avoid incrementing ref from
* zero, then we should return NULL instead.
* Loop on clear-and-set in case someone has modified the reference