Skip to content

Commit 4ccb93c

Browse files
Dave Jonesdavem330
Dave Jones
authored andcommitted
x25: Fix broken locking in ioctl error paths.
Two of the x25 ioctl cases have error paths that break out of the function without unlocking the socket, leading to this warning: ================================================ [ BUG: lock held when returning to user space! ] 3.10.0-rc7+ torvalds#36 Not tainted ------------------------------------------------ trinity-child2/31407 is leaving the kernel with locks still held! 1 lock held by trinity-child2/31407: #0: (sk_lock-AF_X25){+.+.+.}, at: [<ffffffffa024b6da>] x25_ioctl+0x8a/0x740 [x25] Signed-off-by: Dave Jones <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent aec0a40 commit 4ccb93c

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Diff for: net/x25/af_x25.c

+8-7
Original file line numberDiff line numberDiff line change
@@ -1583,26 +1583,27 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
15831583
case SIOCX25CALLACCPTAPPRV: {
15841584
rc = -EINVAL;
15851585
lock_sock(sk);
1586-
if (sk->sk_state != TCP_CLOSE)
1587-
break;
1588-
clear_bit(X25_ACCPT_APPRV_FLAG, &x25->flags);
1586+
if (sk->sk_state == TCP_CLOSE) {
1587+
clear_bit(X25_ACCPT_APPRV_FLAG, &x25->flags);
1588+
rc = 0;
1589+
}
15891590
release_sock(sk);
1590-
rc = 0;
15911591
break;
15921592
}
15931593

15941594
case SIOCX25SENDCALLACCPT: {
15951595
rc = -EINVAL;
15961596
lock_sock(sk);
15971597
if (sk->sk_state != TCP_ESTABLISHED)
1598-
break;
1598+
goto out_sendcallaccpt_release;
15991599
/* must call accptapprv above */
16001600
if (test_bit(X25_ACCPT_APPRV_FLAG, &x25->flags))
1601-
break;
1601+
goto out_sendcallaccpt_release;
16021602
x25_write_internal(sk, X25_CALL_ACCEPTED);
16031603
x25->state = X25_STATE_3;
1604-
release_sock(sk);
16051604
rc = 0;
1605+
out_sendcallaccpt_release:
1606+
release_sock(sk);
16061607
break;
16071608
}
16081609

0 commit comments

Comments
 (0)