diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2012-02-22 12:06:34 -0500 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-02-23 06:07:00 -0500 |
commit | 24c54a90527ca5b85e7feedde2c779dc056ffddb (patch) | |
tree | 4c3bf52346cc63742f37e772b3ff22a1b4e96193 /net/bluetooth/mgmt.c | |
parent | f51d5b248981d05269e4f83ab8f8ed7ed494fe33 (diff) |
Bluetooth: Disabling discoverable with timeout is invalid
Add one extra sanity check to ensure that the supplied timeout value is
actually valid in this context.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r-- | net/bluetooth/mgmt.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index d756644163bc..6df4af6e99cc 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -850,13 +850,16 @@ static int set_discoverable(struct sock *sk, u16 index, void *data, u16 len) | |||
850 | return cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE, | 850 | return cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE, |
851 | MGMT_STATUS_INVALID_PARAMS); | 851 | MGMT_STATUS_INVALID_PARAMS); |
852 | 852 | ||
853 | timeout = get_unaligned_le16(&cp->timeout); | ||
854 | if (!cp->val && timeout > 0) | ||
855 | return cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE, | ||
856 | MGMT_STATUS_INVALID_PARAMS); | ||
857 | |||
853 | hdev = hci_dev_get(index); | 858 | hdev = hci_dev_get(index); |
854 | if (!hdev) | 859 | if (!hdev) |
855 | return cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE, | 860 | return cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE, |
856 | MGMT_STATUS_INVALID_PARAMS); | 861 | MGMT_STATUS_INVALID_PARAMS); |
857 | 862 | ||
858 | timeout = get_unaligned_le16(&cp->timeout); | ||
859 | |||
860 | hci_dev_lock(hdev); | 863 | hci_dev_lock(hdev); |
861 | 864 | ||
862 | if (!hdev_is_powered(hdev) && timeout > 0) { | 865 | if (!hdev_is_powered(hdev) && timeout > 0) { |