Bluetooth: btusb: fix PM leak in error case of setup

This change “Bluetooth: btusb: fix PM leak in error case of setup” (commit 3d44a6f) in Linux kernel is authored by Oliver Neukum <oneukum [at] suse.com> on Thu Nov 14 16:01:18 2019 +0100.

Description of "Bluetooth: btusb: fix PM leak in error case of setup"

The change “Bluetooth: btusb: fix PM leak in error case of setup” introduces changes as follows.

Bluetooth: btusb: fix PM leak in error case of setup

If setup() fails a reference for runtime PM has already
been taken. Proper use of the error handling in btusb_open()is needed.
You cannot just return.

Fixes: ace31982585a3 ("Bluetooth: btusb: Add setup callback for chip init on USB")
Signed-off-by: Oliver Neukum <oneukum@suse.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

Linux kernel releases containing commit 3d44a6f

Linux kernel code changes from "Bluetooth: btusb: fix PM leak in error case of setup"

There are 3 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/bluetooth/btusb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
 
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 04a139e7793f..70e385987d41 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -1200,7 +1200,7 @@ static int btusb_open(struct hci_dev *hdev)
 	if (data->setup_on_usb) {
 		err = data->setup_on_usb(hdev);
 		if (err < 0)
-			return err;
+			goto setup_fail;
 	}
 
 	data->intf->needs_remote_wakeup = 1;
@@ -1239,6 +1239,7 @@ static int btusb_open(struct hci_dev *hdev)
 
 failed:
 	clear_bit(BTUSB_INTR_RUNNING, &data->flags);
+setup_fail:
 	usb_autopm_put_interface(data->intf);
 	return err;
 }

The commit for this change in Linux stable tree is 3d44a6f (patch).

Last modified: 2020/02/08