diff options
author | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-06-17 15:15:10 -0400 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-06-17 15:15:10 -0400 |
commit | a7925bd27d6ef020b8f3a3a64bde61d0add07220 (patch) | |
tree | f3ac64e1292b99961635faa01d37c92d39937245 /net/bluetooth | |
parent | e2ab43536c53ba112a0adfb4c0dba286544c41f6 (diff) |
Bluetooth: Fix locking in blacklist code
There was no unlock call on the errors path
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/hci_core.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 8f5bee15e872..0029e178e52e 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -1241,47 +1241,59 @@ int hci_blacklist_clear(struct hci_dev *hdev) | |||
1241 | int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr) | 1241 | int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr) |
1242 | { | 1242 | { |
1243 | struct bdaddr_list *entry; | 1243 | struct bdaddr_list *entry; |
1244 | 1244 | int err; | |
1245 | hci_dev_lock(hdev); | ||
1246 | 1245 | ||
1247 | if (bacmp(bdaddr, BDADDR_ANY) == 0) | 1246 | if (bacmp(bdaddr, BDADDR_ANY) == 0) |
1248 | return -EBADF; | 1247 | return -EBADF; |
1249 | 1248 | ||
1250 | if (hci_blacklist_lookup(hdev, bdaddr)) | 1249 | hci_dev_lock(hdev); |
1251 | return -EEXIST; | 1250 | |
1251 | if (hci_blacklist_lookup(hdev, bdaddr)) { | ||
1252 | err = -EEXIST; | ||
1253 | goto err; | ||
1254 | } | ||
1252 | 1255 | ||
1253 | entry = kzalloc(sizeof(struct bdaddr_list), GFP_KERNEL); | 1256 | entry = kzalloc(sizeof(struct bdaddr_list), GFP_KERNEL); |
1254 | if (!entry) | 1257 | if (!entry) { |
1255 | return -ENOMEM; | 1258 | return -ENOMEM; |
1259 | goto err; | ||
1260 | } | ||
1256 | 1261 | ||
1257 | bacpy(&entry->bdaddr, bdaddr); | 1262 | bacpy(&entry->bdaddr, bdaddr); |
1258 | 1263 | ||
1259 | list_add(&entry->list, &hdev->blacklist); | 1264 | list_add(&entry->list, &hdev->blacklist); |
1260 | 1265 | ||
1261 | hci_dev_unlock(hdev); | 1266 | err = 0; |
1262 | 1267 | ||
1263 | return 0; | 1268 | err: |
1269 | hci_dev_unlock(hdev); | ||
1270 | return err; | ||
1264 | } | 1271 | } |
1265 | 1272 | ||
1266 | int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr) | 1273 | int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr) |
1267 | { | 1274 | { |
1268 | struct bdaddr_list *entry; | 1275 | struct bdaddr_list *entry; |
1276 | int err = 0; | ||
1269 | 1277 | ||
1270 | hci_dev_lock(hdev); | 1278 | hci_dev_lock(hdev); |
1271 | 1279 | ||
1272 | if (bacmp(bdaddr, BDADDR_ANY) == 0) | 1280 | if (bacmp(bdaddr, BDADDR_ANY) == 0) { |
1273 | return hci_blacklist_clear(hdev); | 1281 | hci_blacklist_clear(hdev); |
1282 | goto done; | ||
1283 | } | ||
1274 | 1284 | ||
1275 | entry = hci_blacklist_lookup(hdev, bdaddr); | 1285 | entry = hci_blacklist_lookup(hdev, bdaddr); |
1276 | if (!entry) | 1286 | if (!entry) { |
1277 | return -ENOENT; | 1287 | err = -ENOENT; |
1288 | goto done; | ||
1289 | } | ||
1278 | 1290 | ||
1279 | list_del(&entry->list); | 1291 | list_del(&entry->list); |
1280 | kfree(entry); | 1292 | kfree(entry); |
1281 | 1293 | ||
1294 | done: | ||
1282 | hci_dev_unlock(hdev); | 1295 | hci_dev_unlock(hdev); |
1283 | 1296 | return err; | |
1284 | return 0; | ||
1285 | } | 1297 | } |
1286 | 1298 | ||
1287 | static void hci_clear_adv_cache(unsigned long arg) | 1299 | static void hci_clear_adv_cache(unsigned long arg) |