Skip to content

Commit

Permalink
Bluetooth: serialize calls to sco_sock_{set,clear}_timer
Browse files Browse the repository at this point in the history
Currently, calls to sco_sock_set_timer are made under the locked
socket, but this does not apply to all calls to sco_sock_clear_timer.

Both sco_sock_{set,clear}_timer should be serialized by lock_sock to
prevent unexpected concurrent clearing/setting of timers.

Additionally, since sco_pi(sk)->conn is only cleared under the locked
socket, this change allows us to avoid races between
sco_sock_clear_timer and the call to kfree(conn) in sco_conn_del.

Signed-off-by: Desmond Cheong Zhi Xi <[email protected]>
Signed-off-by: Luiz Augusto von Dentz <[email protected]>
  • Loading branch information
desmondcheongzx authored and Vudentz committed Aug 10, 2021
1 parent 27c24fd commit 3f2c89f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/bluetooth/sco.c
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,8 @@ static void __sco_sock_close(struct sock *sk)
/* Must be called on unlocked socket. */
static void sco_sock_close(struct sock *sk)
{
sco_sock_clear_timer(sk);
lock_sock(sk);
sco_sock_clear_timer(sk);
__sco_sock_close(sk);
release_sock(sk);
sco_sock_kill(sk);
Expand Down Expand Up @@ -1104,8 +1104,8 @@ static void sco_conn_ready(struct sco_conn *conn)
BT_DBG("conn %p", conn);

if (sk) {
sco_sock_clear_timer(sk);
lock_sock(sk);
sco_sock_clear_timer(sk);
sk->sk_state = BT_CONNECTED;
sk->sk_state_change(sk);
release_sock(sk);
Expand Down

0 comments on commit 3f2c89f

Please sign in to comment.