Commit 1de028ce authored by Johan Hedberg's avatar Johan Hedberg Committed by Gustavo F. Padovan

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: default avatarGustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
parent 00abfe44
...@@ -1273,10 +1273,12 @@ static int set_le(struct sock *sk, u16 index, void *data, u16 len) ...@@ -1273,10 +1273,12 @@ static int set_le(struct sock *sk, u16 index, void *data, u16 len)
return cmd_status(sk, index, MGMT_OP_SET_LE, return cmd_status(sk, index, MGMT_OP_SET_LE,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
hci_dev_lock(hdev);
if (!enable_le || !(hdev->features[4] & LMP_LE)) { if (!enable_le || !(hdev->features[4] & LMP_LE)) {
err = cmd_status(sk, index, MGMT_OP_SET_LE, err = cmd_status(sk, index, MGMT_OP_SET_LE,
MGMT_STATUS_NOT_SUPPORTED); MGMT_STATUS_NOT_SUPPORTED);
goto failed; goto unlock;
} }
val = !!cp->val; val = !!cp->val;
...@@ -1292,23 +1294,23 @@ static int set_le(struct sock *sk, u16 index, void *data, u16 len) ...@@ -1292,23 +1294,23 @@ static int set_le(struct sock *sk, u16 index, void *data, u16 len)
err = send_settings_rsp(sk, MGMT_OP_SET_LE, hdev); err = send_settings_rsp(sk, MGMT_OP_SET_LE, hdev);
if (err < 0) if (err < 0)
goto failed; goto unlock;
if (changed) if (changed)
err = new_settings(hdev, sk); err = new_settings(hdev, sk);
goto failed; goto unlock;
} }
if (mgmt_pending_find(MGMT_OP_SET_LE, hdev)) { if (mgmt_pending_find(MGMT_OP_SET_LE, hdev)) {
err = cmd_status(sk, index, MGMT_OP_SET_LE, MGMT_STATUS_BUSY); err = cmd_status(sk, index, MGMT_OP_SET_LE, MGMT_STATUS_BUSY);
goto failed; goto unlock;
} }
cmd = mgmt_pending_add(sk, MGMT_OP_SET_LE, hdev, data, len); cmd = mgmt_pending_add(sk, MGMT_OP_SET_LE, hdev, data, len);
if (!cmd) { if (!cmd) {
err = -ENOMEM; err = -ENOMEM;
goto failed; goto unlock;
} }
memset(&hci_cp, 0, sizeof(hci_cp)); 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,10 +1324,11 @@ static int set_le(struct sock *sk, u16 index, void *data, u16 len)
sizeof(hci_cp), &hci_cp); sizeof(hci_cp), &hci_cp);
if (err < 0) { if (err < 0) {
mgmt_pending_remove(cmd); mgmt_pending_remove(cmd);
goto failed; goto unlock;
} }
failed: unlock:
hci_dev_unlock(hdev);
hci_dev_put(hdev); hci_dev_put(hdev);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment