Skip to contentSkip to conversation

btusb: fix PM leak in error case of setup

PATCH In review Oliver Neukum 2 participants 2 messages Nov 14, 2019 – Nov 15, 2019 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")

---
 drivers/bluetooth/btusb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/bluetooth/btusb.c +2 -1
index a9c35ebb30f8..0b5e4c135f78 100644
@@ -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;
 }
Signature · 1 line
2.16.4
maintainer
#1 lore raw

Hi Oliver,

Quoted 10 lines

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")

---
drivers/bluetooth/btusb.c | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel