bluetooth: Add HCI device to device list after initialization

Avoid possible NULL pointer dereference when ioctl is called while
device is not fully initailized

Change-Id: Ie796fb070a5bf0c6f11e796152c4a84280d40021
Signed-off-by: Kamal Negi <kamaln@codeaurora.org>
This commit is contained in:
Kamal Negi 2014-11-18 16:23:15 +05:30
parent 7c3d564c2b
commit 52f33ca808
1 changed files with 4 additions and 4 deletions

View File

@ -2217,10 +2217,6 @@ int hci_register_dev(struct hci_dev *hdev)
BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus);
write_lock(&hci_dev_list_lock);
list_add(&hdev->list, &hci_dev_list);
write_unlock(&hci_dev_list_lock);
hdev->workqueue = alloc_workqueue(hdev->name, WQ_HIGHPRI | WQ_UNBOUND |
WQ_MEM_RECLAIM, 1);
if (!hdev->workqueue) {
@ -2259,6 +2255,10 @@ int hci_register_dev(struct hci_dev *hdev)
if (hdev->dev_type != HCI_AMP)
set_bit(HCI_AUTO_OFF, &hdev->dev_flags);
write_lock(&hci_dev_list_lock);
list_add(&hdev->list, &hci_dev_list);
write_unlock(&hci_dev_list_lock);
hci_notify(hdev, HCI_DEV_REG);
hci_dev_hold(hdev);