Bluetooth: btusb: fix PM leak in error case of setup
authorOliver Neukum <oneukum@suse.com>
Thu, 14 Nov 2019 15:01:18 +0000 (16:01 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jan 2020 09:17:57 +0000 (10:17 +0100)
commit 3d44a6fd0775e6215e836423e27f8eedf8c871ea upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/bluetooth/btusb.c

index 73561bfd95d43b18848c1742911f4627587dff75..424f399cc79b4ae78c8361f982459db0fab99e2c 100644 (file)
@@ -1123,7 +1123,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;
@@ -1155,6 +1155,7 @@ done:
 
 failed:
        clear_bit(BTUSB_INTR_RUNNING, &data->flags);
+setup_fail:
        usb_autopm_put_interface(data->intf);
        return err;
 }