Commit a7925bd2 authored by Gustavo F. Padovan's avatar Gustavo F. Padovan

Bluetooth: Fix locking in blacklist code

There was no unlock call on the errors path
Signed-off-by: default avatarGustavo F. Padovan <padovan@profusion.mobi>
parent e2ab4353
...@@ -1241,47 +1241,59 @@ int hci_blacklist_clear(struct hci_dev *hdev) ...@@ -1241,47 +1241,59 @@ int hci_blacklist_clear(struct hci_dev *hdev)
int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr) int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr)
{ {
struct bdaddr_list *entry; struct bdaddr_list *entry;
int err;
hci_dev_lock(hdev);
if (bacmp(bdaddr, BDADDR_ANY) == 0) if (bacmp(bdaddr, BDADDR_ANY) == 0)
return -EBADF; return -EBADF;
if (hci_blacklist_lookup(hdev, bdaddr)) hci_dev_lock(hdev);
return -EEXIST;
if (hci_blacklist_lookup(hdev, bdaddr)) {
err = -EEXIST;
goto err;
}
entry = kzalloc(sizeof(struct bdaddr_list), GFP_KERNEL); entry = kzalloc(sizeof(struct bdaddr_list), GFP_KERNEL);
if (!entry) if (!entry) {
return -ENOMEM; return -ENOMEM;
goto err;
}
bacpy(&entry->bdaddr, bdaddr); bacpy(&entry->bdaddr, bdaddr);
list_add(&entry->list, &hdev->blacklist); list_add(&entry->list, &hdev->blacklist);
hci_dev_unlock(hdev); err = 0;
return 0; err:
hci_dev_unlock(hdev);
return err;
} }
int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr) int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr)
{ {
struct bdaddr_list *entry; struct bdaddr_list *entry;
int err = 0;
hci_dev_lock(hdev); hci_dev_lock(hdev);
if (bacmp(bdaddr, BDADDR_ANY) == 0) if (bacmp(bdaddr, BDADDR_ANY) == 0) {
return hci_blacklist_clear(hdev); hci_blacklist_clear(hdev);
goto done;
}
entry = hci_blacklist_lookup(hdev, bdaddr); entry = hci_blacklist_lookup(hdev, bdaddr);
if (!entry) if (!entry) {
return -ENOENT; err = -ENOENT;
goto done;
}
list_del(&entry->list); list_del(&entry->list);
kfree(entry); kfree(entry);
done:
hci_dev_unlock(hdev); hci_dev_unlock(hdev);
return err;
return 0;
} }
static void hci_clear_adv_cache(unsigned long arg) static void hci_clear_adv_cache(unsigned long arg)
......
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