Skip to content

Commit

Permalink
Bluetooth: Limit HCI raw socket options to actual raw sockets
Browse files Browse the repository at this point in the history
Currently the socket options of HCI sockets can be set on raw and control
sockets, but on control sockets they make no sense. So just return EINVAL
in that case.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
  • Loading branch information
Marcel Holtmann authored and Johan Hedberg committed Feb 20, 2012
1 parent a6fb08d commit 2f39cdb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions net/bluetooth/hci_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,11 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname, char

lock_sock(sk);

if (hci_pi(sk)->channel != HCI_CHANNEL_RAW) {
err = -EINVAL;
goto done;
}

switch (optname) {
case HCI_DATA_DIR:
if (get_user(opt, (int __user *)optval)) {
Expand Down Expand Up @@ -663,6 +668,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname, char
break;
}

done:
release_sock(sk);
return err;
}
Expand Down

0 comments on commit 2f39cdb

Please sign in to comment.