diff
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -19,6 +19,7 @@
 18 
 19 	msft_unregister(hdev);
 20 
+        hci_dev_set_flag(hdev, HCI_MSFT_UNREGISTERED);
 21 	hci_dev_do_close(hdev);
 22 
 23 	if (!test_bit(HCI_INIT, &hdev->flags) &&
@@ -44,3 +45,14 @@
 43 	/* Actual cleanup is deferred until hci_release_dev(). */
 44 	hci_dev_put(hdev);
 45 }
+
+// ... (in hci_release_dev)
+void hci_release_dev(struct kref *kref)
+{
+    // ... other cleanup ...
+
+    if (hci_dev_test_flag(hdev, HCI_MSFT_UNREGISTERED)) {
+        // Perform any additional cleanup related to msft_unregister 
+    }
+
+    // ... rest of hci_release_dev ...
+}
