Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 52f33ca8 authored by Kamal Negi's avatar Kamal Negi
Browse files

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: default avatarKamal Negi <kamaln@codeaurora.org>
parent 7c3d564c
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -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);