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(), the local, non shared, variable "old"
is used as an atomic target:
atomic_val_t old = atomic_dec(&conn->ref);
conn = NULL;
bool deallocated = (atomic_get(&old) == 1);
The above call to atomic_get() does not prevent any data race
or value obsolescence.
The resulting additional memory barrier does not seem necessary either.
If pedantic, one could also note that 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.
While rewording comments,also emphasize that using
freed slots to automatically resume advertising
from bt_conn_unref() is a deprecated behavior.
Signed-off-by: Christophe Dufaza <[email protected]>
0 commit comments