Skip to content

Commit e6da0ed

Browse files
Sebastian Andrzej Siewiorholtmann
authored andcommitted
Bluetooth: Acquire sk_lock.slock without disabling interrupts
There was a lockdep which led to commit fad003b ("Bluetooth: Fix inconsistent lock state with RFCOMM") Lockdep noticed that `sk->sk_lock.slock' was acquired without disabling the softirq while the lock was also used in softirq context. Unfortunately the solution back then was to disable interrupts before acquiring the lock which however made lockdep happy. It would have been enough to simply disable the softirq. Disabling interrupts before acquiring a spinlock_t is not allowed on PREEMPT_RT because these locks are converted to 'sleeping' spinlocks. Use spin_lock_bh() in order to acquire the `sk_lock.slock'. Reported-by: Luis Claudio R. Goncalves <[email protected]> Reported-by: kbuild test robot <[email protected]> [missing unlock] Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent 4803c54 commit e6da0ed

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

net/bluetooth/rfcomm/sock.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,13 @@ static void rfcomm_sk_data_ready(struct rfcomm_dlc *d, struct sk_buff *skb)
6464
static void rfcomm_sk_state_change(struct rfcomm_dlc *d, int err)
6565
{
6666
struct sock *sk = d->owner, *parent;
67-
unsigned long flags;
6867

6968
if (!sk)
7069
return;
7170

7271
BT_DBG("dlc %p state %ld err %d", d, d->state, err);
7372

74-
local_irq_save(flags);
75-
bh_lock_sock(sk);
73+
spin_lock_bh(&sk->sk_lock.slock);
7674

7775
if (err)
7876
sk->sk_err = err;
@@ -93,8 +91,7 @@ static void rfcomm_sk_state_change(struct rfcomm_dlc *d, int err)
9391
sk->sk_state_change(sk);
9492
}
9593

96-
bh_unlock_sock(sk);
97-
local_irq_restore(flags);
94+
spin_unlock_bh(&sk->sk_lock.slock);
9895

9996
if (parent && sock_flag(sk, SOCK_ZAPPED)) {
10097
/* We have to drop DLC lock here, otherwise

0 commit comments

Comments
 (0)