Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Bluetooth: Fix crash when using new BT_PHY option

This fixes the invalid check for connected socket which causes the
following trace due to sco_pi(sk)->conn being NULL:

RIP: 0010:sco_sock_getsockopt+0x2ff/0x800 net/bluetooth/sco.c:966

L2CAP has also been fixed since it has the same problem.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

authored by

Luiz Augusto von Dentz and committed by
Marcel Holtmann
a2a8b0b4 0830c0a4

+2 -2
+1 -1
net/bluetooth/l2cap_sock.c
··· 605 605 break; 606 606 607 607 case BT_PHY: 608 - if (sk->sk_state == BT_CONNECTED) { 608 + if (sk->sk_state != BT_CONNECTED) { 609 609 err = -ENOTCONN; 610 610 break; 611 611 }
+1 -1
net/bluetooth/sco.c
··· 958 958 break; 959 959 960 960 case BT_PHY: 961 - if (sk->sk_state == BT_CONNECTED) { 961 + if (sk->sk_state != BT_CONNECTED) { 962 962 err = -ENOTCONN; 963 963 break; 964 964 }