summaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_sock.c
diff options
context:
space:
mode:
authorMarcel Holtmann2012-02-20 14:50:32 +0100
committerJohan Hedberg2012-02-20 14:55:54 +0100
commit2f39cdb7a270da24532734dfdfd10c490be981c4 (patch)
tree23287d6082f8dca48ea1631b6bbbcece87c825d4 /net/bluetooth/hci_sock.c
parentBluetooth: Remove unneeded bt_cb(skb)->channel variable (diff)
downloadkernel-qcow2-linux-2f39cdb7a270da24532734dfdfd10c490be981c4.tar.gz
kernel-qcow2-linux-2f39cdb7a270da24532734dfdfd10c490be981c4.tar.xz
kernel-qcow2-linux-2f39cdb7a270da24532734dfdfd10c490be981c4.zip
Bluetooth: Limit HCI raw socket options to actual raw sockets
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>
Diffstat (limited to 'net/bluetooth/hci_sock.c')
-rw-r--r--net/bluetooth/hci_sock.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index b5b3bc8d2848..612bc2af05a9 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -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)) {
@@ -663,6 +668,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname, char
break;
}
+done:
release_sock(sk);
return err;
}