Bluetooth: hci_core: cancel power off delayed work properly

When the HCI_AUTO_OFF flag is cleared, the power_off delayed work need
to be cancel or HCI will be powered off even if it's managed.

Signed-off-by: Wei-Ning Huang <>
Signed-off-by: Marcel Holtmann <>

Change-Id: Idc421b741c45b1be1b4336944ba268c249378743
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 06f603a..aba6ac8 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2021,6 +2021,7 @@
 	if (test_bit(HCI_UP, &hdev->flags) &&
 	    hci_dev_test_flag(hdev, HCI_MGMT) &&
 	    hci_dev_test_and_clear_flag(hdev, HCI_AUTO_OFF)) {
+		cancel_delayed_work(&hdev->power_off);
 		err = __hci_req_hci_power_on(hdev);