]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
Bluetooth: hci_qca: Cleanup on all setup failures
authorJinwang Li <jinwang.li@oss.qualcomm.com>
Thu, 5 Feb 2026 06:26:00 +0000 (14:26 +0800)
committerSasha Levin <sashal@kernel.org>
Wed, 4 Mar 2026 12:20:54 +0000 (07:20 -0500)
[ Upstream commit 5c4e9a8b18457ad28b57069ef0f14661e3192b2e ]

The setup process previously combined error handling and retry gating
under one condition. As a result, the final failed attempt exited
without performing cleanup.

Update the failure path to always perform power and port cleanup on
setup failure, and reopen the port only when retrying.

Fixes: 9e80587aba4c ("Bluetooth: hci_qca: Enhance retry logic in qca_setup")
Signed-off-by: Jinwang Li <jinwang.li@oss.qualcomm.com>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/bluetooth/hci_qca.c

index a3c217571c3c45fe614755687bc8a87977f35da4..c0cc04995fc2faeafe846b0fdcbdc8ae4429608d 100644 (file)
@@ -2045,19 +2045,23 @@ retry:
        }
 
 out:
-       if (ret && retries < MAX_INIT_RETRIES) {
-               bt_dev_warn(hdev, "Retry BT power ON:%d", retries);
+       if (ret) {
                qca_power_shutdown(hu);
-               if (hu->serdev) {
-                       serdev_device_close(hu->serdev);
-                       ret = serdev_device_open(hu->serdev);
-                       if (ret) {
-                               bt_dev_err(hdev, "failed to open port");
-                               return ret;
+
+               if (retries < MAX_INIT_RETRIES) {
+                       bt_dev_warn(hdev, "Retry BT power ON:%d", retries);
+                       if (hu->serdev) {
+                               serdev_device_close(hu->serdev);
+                               ret = serdev_device_open(hu->serdev);
+                               if (ret) {
+                                       bt_dev_err(hdev, "failed to open port");
+                                       return ret;
+                               }
                        }
+                       retries++;
+                       goto retry;
                }
-               retries++;
-               goto retry;
+               return ret;
        }
 
        /* Setup bdaddr */