diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 7ed5d6e47e4f..cd4d931368a0 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3706,6 +3706,9 @@ static int hci_suspend_notifier(struct notifier_block *nb, unsigned long action, int ret = 0; u8 state = BT_RUNNING; + /* To avoid a potential race with hci_unregister_dev. */ + hci_dev_hold(hdev); + /* If powering down, wait for completion. */ if (mgmt_powering_down(hdev)) { set_bit(SUSPEND_POWERING_DOWN, hdev->suspend_tasks); @@ -3757,6 +3760,7 @@ static int hci_suspend_notifier(struct notifier_block *nb, unsigned long action, bt_dev_err(hdev, "Suspend notifier action (%lu) failed: %d", action, ret); + hci_dev_put(hdev); return NOTIFY_DONE; }