]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
Bluetooth: mgmt: Fix set_fast_connectable error return
authorJohan Hedberg <johan.hedberg@intel.com>
Tue, 21 Feb 2012 14:40:33 +0000 (16:40 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Tue, 21 Feb 2012 16:48:20 +0000 (18:48 +0200)
This patch ensures that Set Fast Connectable fails apropriately if we
are not already in a connectable state (which is a pre-requisite for
fast connectable).

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
net/bluetooth/mgmt.c

index 03a13843cd1624a2e6b89e506f18dd9037ba95bc..563190c9f7b0e714a18d11d08e1cd249183bfcf5 100644 (file)
@@ -2560,6 +2560,13 @@ static int set_fast_connectable(struct sock *sk, u16 index,
        if (!hdev)
                return cmd_status(sk, index, MGMT_OP_SET_FAST_CONNECTABLE,
                                                MGMT_STATUS_INVALID_PARAMS);
+       if (!hdev_is_powered(hdev))
+               return cmd_status(sk, index, MGMT_OP_SET_FAST_CONNECTABLE,
+                                               MGMT_STATUS_NOT_POWERED);
+
+       if (!test_bit(HCI_CONNECTABLE, &hdev->dev_flags))
+               return cmd_status(sk, index, MGMT_OP_SET_FAST_CONNECTABLE,
+                                                       MGMT_STATUS_REJECTED);
 
        hci_dev_lock(hdev);