diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2012-02-29 22:55:35 -0500 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2012-02-29 23:28:04 -0500 |
commit | 1de028ceb54ccd28cc96f1530a195ae1b6a6d5b5 (patch) | |
tree | 17b1f270a183af3bd785dc1009c10f82a8212a43 /net/bluetooth | |
parent | 00abfe4442864144a77f70b6b411d691bcb796bf (diff) |
Bluetooth: mgmt: Add missing hci_dev locking to set_le()
The set_le() function was missing hci_dev locking which is e.g. critical
for the mgmt pending command adding/removing.
Acked-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/mgmt.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 373b46a9eb17..abf1adb8bc16 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -1273,10 +1273,12 @@ static int set_le(struct sock *sk, u16 index, void *data, u16 len) | |||
1273 | return cmd_status(sk, index, MGMT_OP_SET_LE, | 1273 | return cmd_status(sk, index, MGMT_OP_SET_LE, |
1274 | MGMT_STATUS_INVALID_PARAMS); | 1274 | MGMT_STATUS_INVALID_PARAMS); |
1275 | 1275 | ||
1276 | hci_dev_lock(hdev); | ||
1277 | |||
1276 | if (!enable_le || !(hdev->features[4] & LMP_LE)) { | 1278 | if (!enable_le || !(hdev->features[4] & LMP_LE)) { |
1277 | err = cmd_status(sk, index, MGMT_OP_SET_LE, | 1279 | err = cmd_status(sk, index, MGMT_OP_SET_LE, |
1278 | MGMT_STATUS_NOT_SUPPORTED); | 1280 | MGMT_STATUS_NOT_SUPPORTED); |
1279 | goto failed; | 1281 | goto unlock; |
1280 | } | 1282 | } |
1281 | 1283 | ||
1282 | val = !!cp->val; | 1284 | val = !!cp->val; |
@@ -1292,23 +1294,23 @@ static int set_le(struct sock *sk, u16 index, void *data, u16 len) | |||
1292 | 1294 | ||
1293 | err = send_settings_rsp(sk, MGMT_OP_SET_LE, hdev); | 1295 | err = send_settings_rsp(sk, MGMT_OP_SET_LE, hdev); |
1294 | if (err < 0) | 1296 | if (err < 0) |
1295 | goto failed; | 1297 | goto unlock; |
1296 | 1298 | ||
1297 | if (changed) | 1299 | if (changed) |
1298 | err = new_settings(hdev, sk); | 1300 | err = new_settings(hdev, sk); |
1299 | 1301 | ||
1300 | goto failed; | 1302 | goto unlock; |
1301 | } | 1303 | } |
1302 | 1304 | ||
1303 | if (mgmt_pending_find(MGMT_OP_SET_LE, hdev)) { | 1305 | if (mgmt_pending_find(MGMT_OP_SET_LE, hdev)) { |
1304 | err = cmd_status(sk, index, MGMT_OP_SET_LE, MGMT_STATUS_BUSY); | 1306 | err = cmd_status(sk, index, MGMT_OP_SET_LE, MGMT_STATUS_BUSY); |
1305 | goto failed; | 1307 | goto unlock; |
1306 | } | 1308 | } |
1307 | 1309 | ||
1308 | cmd = mgmt_pending_add(sk, MGMT_OP_SET_LE, hdev, data, len); | 1310 | cmd = mgmt_pending_add(sk, MGMT_OP_SET_LE, hdev, data, len); |
1309 | if (!cmd) { | 1311 | if (!cmd) { |
1310 | err = -ENOMEM; | 1312 | err = -ENOMEM; |
1311 | goto failed; | 1313 | goto unlock; |
1312 | } | 1314 | } |
1313 | 1315 | ||
1314 | memset(&hci_cp, 0, sizeof(hci_cp)); | 1316 | memset(&hci_cp, 0, sizeof(hci_cp)); |
@@ -1322,10 +1324,11 @@ static int set_le(struct sock *sk, u16 index, void *data, u16 len) | |||
1322 | sizeof(hci_cp), &hci_cp); | 1324 | sizeof(hci_cp), &hci_cp); |
1323 | if (err < 0) { | 1325 | if (err < 0) { |
1324 | mgmt_pending_remove(cmd); | 1326 | mgmt_pending_remove(cmd); |
1325 | goto failed; | 1327 | goto unlock; |
1326 | } | 1328 | } |
1327 | 1329 | ||
1328 | failed: | 1330 | unlock: |
1331 | hci_dev_unlock(hdev); | ||
1329 | hci_dev_put(hdev); | 1332 | hci_dev_put(hdev); |
1330 | return err; | 1333 | return err; |
1331 | } | 1334 | } |