Skip to content

Commit

Permalink
Bluetooth: Fix crash when using new BT_PHY option
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Luiz Augusto von Dentz authored and Marcel Holtmann committed Feb 18, 2020
1 parent 0830c0a commit a2a8b0b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion net/bluetooth/l2cap_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname,
break;

case BT_PHY:
if (sk->sk_state == BT_CONNECTED) {
if (sk->sk_state != BT_CONNECTED) {
err = -ENOTCONN;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion net/bluetooth/sco.c
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ static int sco_sock_getsockopt(struct socket *sock, int level, int optname,
break;

case BT_PHY:
if (sk->sk_state == BT_CONNECTED) {
if (sk->sk_state != BT_CONNECTED) {
err = -ENOTCONN;
break;
}
Expand Down

0 comments on commit a2a8b0b

Please sign in to comment.