aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2012-02-22 15:41:18 -0500
committerJohan Hedberg <johan.hedberg@intel.com>2012-02-23 06:07:01 -0500
commit5f97c1df5563349795f26ed249e2a8840237c569 (patch)
treebca313ffb988577257e51117a8845ddebd86e8dc /net/bluetooth
parent932f5ff5e32bf520eb9287b050c926faa6e76bcf (diff)
Bluetooth: mgmt: Add missing powered checks to commands
This patch adds missing powered checks to pair_device, cancel_pair_device, add_remote_oob_data and remove_remote_oob_data. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/mgmt.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index a45c2b70dfdb..7c7bc2a21393 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1735,6 +1735,12 @@ static int get_connections(struct sock *sk, u16 index)
1735 1735
1736 hci_dev_lock(hdev); 1736 hci_dev_lock(hdev);
1737 1737
1738 if (!hdev_is_powered(hdev)) {
1739 err = cmd_status(sk, index, MGMT_OP_GET_CONNECTIONS,
1740 MGMT_STATUS_NOT_POWERED);
1741 goto unlock;
1742 }
1743
1738 count = 0; 1744 count = 0;
1739 list_for_each_entry(c, &hdev->conn_hash.list, list) { 1745 list_for_each_entry(c, &hdev->conn_hash.list, list) {
1740 if (test_bit(HCI_CONN_MGMT_CONNECTED, &c->flags)) 1746 if (test_bit(HCI_CONN_MGMT_CONNECTED, &c->flags))
@@ -1766,8 +1772,9 @@ static int get_connections(struct sock *sk, u16 index)
1766 1772
1767 err = cmd_complete(sk, index, MGMT_OP_GET_CONNECTIONS, 0, rp, rp_len); 1773 err = cmd_complete(sk, index, MGMT_OP_GET_CONNECTIONS, 0, rp, rp_len);
1768 1774
1769unlock:
1770 kfree(rp); 1775 kfree(rp);
1776
1777unlock:
1771 hci_dev_unlock(hdev); 1778 hci_dev_unlock(hdev);
1772 hci_dev_put(hdev); 1779 hci_dev_put(hdev);
1773 return err; 1780 return err;
@@ -2002,6 +2009,12 @@ static int pair_device(struct sock *sk, u16 index, void *data, u16 len)
2002 2009
2003 hci_dev_lock(hdev); 2010 hci_dev_lock(hdev);
2004 2011
2012 if (!hdev_is_powered(hdev)) {
2013 err = cmd_status(sk, index, MGMT_OP_PAIR_DEVICE,
2014 MGMT_STATUS_NOT_POWERED);
2015 goto unlock;
2016 }
2017
2005 sec_level = BT_SECURITY_MEDIUM; 2018 sec_level = BT_SECURITY_MEDIUM;
2006 if (cp->io_cap == 0x03) 2019 if (cp->io_cap == 0x03)
2007 auth_type = HCI_AT_DEDICATED_BONDING; 2020 auth_type = HCI_AT_DEDICATED_BONDING;
@@ -2084,6 +2097,12 @@ static int cancel_pair_device(struct sock *sk, u16 index,
2084 2097
2085 hci_dev_lock(hdev); 2098 hci_dev_lock(hdev);
2086 2099
2100 if (!hdev_is_powered(hdev)) {
2101 err = cmd_status(sk, index, MGMT_OP_CANCEL_PAIR_DEVICE,
2102 MGMT_STATUS_NOT_POWERED);
2103 goto unlock;
2104 }
2105
2087 cmd = mgmt_pending_find(MGMT_OP_PAIR_DEVICE, hdev); 2106 cmd = mgmt_pending_find(MGMT_OP_PAIR_DEVICE, hdev);
2088 if (!cmd) { 2107 if (!cmd) {
2089 err = cmd_status(sk, index, MGMT_OP_CANCEL_PAIR_DEVICE, 2108 err = cmd_status(sk, index, MGMT_OP_CANCEL_PAIR_DEVICE,
@@ -2375,6 +2394,13 @@ static int add_remote_oob_data(struct sock *sk, u16 index, void *data,
2375 2394
2376 hci_dev_lock(hdev); 2395 hci_dev_lock(hdev);
2377 2396
2397 if (!hdev_is_powered(hdev)) {
2398 err = cmd_complete(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA,
2399 MGMT_STATUS_NOT_POWERED,
2400 &cp->addr, sizeof(cp->addr));
2401 goto unlock;
2402 }
2403
2378 err = hci_add_remote_oob_data(hdev, &cp->addr.bdaddr, cp->hash, 2404 err = hci_add_remote_oob_data(hdev, &cp->addr.bdaddr, cp->hash,
2379 cp->randomizer); 2405 cp->randomizer);
2380 if (err < 0) 2406 if (err < 0)
@@ -2385,6 +2411,7 @@ static int add_remote_oob_data(struct sock *sk, u16 index, void *data,
2385 err = cmd_complete(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA, status, 2411 err = cmd_complete(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA, status,
2386 &cp->addr, sizeof(cp->addr)); 2412 &cp->addr, sizeof(cp->addr));
2387 2413
2414unlock:
2388 hci_dev_unlock(hdev); 2415 hci_dev_unlock(hdev);
2389 hci_dev_put(hdev); 2416 hci_dev_put(hdev);
2390 2417
@@ -2413,6 +2440,13 @@ static int remove_remote_oob_data(struct sock *sk, u16 index,
2413 2440
2414 hci_dev_lock(hdev); 2441 hci_dev_lock(hdev);
2415 2442
2443 if (!hdev_is_powered(hdev)) {
2444 err = cmd_complete(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA,
2445 MGMT_STATUS_NOT_POWERED,
2446 &cp->addr, sizeof(cp->addr));
2447 goto unlock;
2448 }
2449
2416 err = hci_remove_remote_oob_data(hdev, &cp->addr.bdaddr); 2450 err = hci_remove_remote_oob_data(hdev, &cp->addr.bdaddr);
2417 if (err < 0) 2451 if (err < 0)
2418 status = MGMT_STATUS_INVALID_PARAMS; 2452 status = MGMT_STATUS_INVALID_PARAMS;
@@ -2422,6 +2456,7 @@ static int remove_remote_oob_data(struct sock *sk, u16 index,
2422 err = cmd_complete(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA, status, 2456 err = cmd_complete(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA, status,
2423 &cp->addr, sizeof(cp->addr)); 2457 &cp->addr, sizeof(cp->addr));
2424 2458
2459unlock:
2425 hci_dev_unlock(hdev); 2460 hci_dev_unlock(hdev);
2426 hci_dev_put(hdev); 2461 hci_dev_put(hdev);
2427 2462