aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/mgmt.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2012-02-21 07:32:24 -0500
committerJohan Hedberg <johan.hedberg@intel.com>2012-02-21 11:47:46 -0500
commitb5235a65ad19f47c5995f054d3dcce90570d1a1c (patch)
treeb99d4ba00ed6b7920df8c103efcf4e736e3648b8 /net/bluetooth/mgmt.c
parent4b34ee782164fbaf29b2e7c0e8cb3a898c0986ca (diff)
Bluetooth: mgmt: Fix set_local_name and set_dev_class powered checks
Both the Set Local Name and the Set Device Class commands should fail if the adapter is not powered on. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r--net/bluetooth/mgmt.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index c27481c3c95..03a13843cd1 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1272,6 +1272,12 @@ static int set_dev_class(struct sock *sk, u16 index, void *data, u16 len)
1272 1272
1273 hci_dev_lock(hdev); 1273 hci_dev_lock(hdev);
1274 1274
1275 if (!hdev_is_powered(hdev)) {
1276 err = cmd_status(sk, index, MGMT_OP_SET_DEV_CLASS,
1277 MGMT_STATUS_NOT_POWERED);
1278 goto unlock;
1279 }
1280
1275 hdev->major_class = cp->major; 1281 hdev->major_class = cp->major;
1276 hdev->minor_class = cp->minor; 1282 hdev->minor_class = cp->minor;
1277 1283
@@ -1288,6 +1294,7 @@ static int set_dev_class(struct sock *sk, u16 index, void *data, u16 len)
1288 err = cmd_complete(sk, index, MGMT_OP_SET_DEV_CLASS, 0, 1294 err = cmd_complete(sk, index, MGMT_OP_SET_DEV_CLASS, 0,
1289 NULL, 0); 1295 NULL, 0);
1290 1296
1297unlock:
1291 hci_dev_unlock(hdev); 1298 hci_dev_unlock(hdev);
1292 hci_dev_put(hdev); 1299 hci_dev_put(hdev);
1293 1300
@@ -2076,6 +2083,12 @@ static int set_local_name(struct sock *sk, u16 index, void *data,
2076 2083
2077 hci_dev_lock(hdev); 2084 hci_dev_lock(hdev);
2078 2085
2086 if (!hdev_is_powered(hdev)) {
2087 err = cmd_status(sk, index, MGMT_OP_SET_LOCAL_NAME,
2088 MGMT_STATUS_NOT_POWERED);
2089 goto failed;
2090 }
2091
2079 cmd = mgmt_pending_add(sk, MGMT_OP_SET_LOCAL_NAME, hdev, data, 2092 cmd = mgmt_pending_add(sk, MGMT_OP_SET_LOCAL_NAME, hdev, data,
2080 len); 2093 len);
2081 if (!cmd) { 2094 if (!cmd) {