You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bluetooth: Host: Fix use of local variable as atomic target
In bt_conn_unref(), a local variable is used as an atomic target:
atomic_val_t old = atomic_dec(&conn->ref);
/* Prevent from accessing connection object */
bool deallocated = (atomic_get(&old) == 1);
conn = NULL;
The above call to atomic_get() cannot prevent any data race
or value staleness, and only causes confusion.
The comment that seems associated can also be misleading.
If pedantic, we can observe that in any case atomic_get() expects
an atomic_t* argument (target), not an atomic_val_t* (value).
This compiles and /works/ just fine since the Zephyr Atomic API defines
both to be the same integer type.
The equivalent C11 code, where _Atomic(T) and T are different types,
wouldn't compile.
Also add a comment to remind that automatic advertiser resumption
is deprecated.
Signed-off-by: Christophe Dufaza <[email protected]>
0 commit comments