Bluetooth: btusb: Use an error label for error paths
authorRajat Jain <rajatja@google.com>
Wed, 1 Feb 2017 22:24:08 +0000 (14:24 -0800)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 16 Feb 2017 16:21:59 +0000 (17:21 +0100)
Use a label to remove the repetetive cleanup, for error cases.

Signed-off-by: Rajat Jain <rajatja@google.com>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
drivers/bluetooth/btusb.c

index fa4d9313442e6d559878b57ae3f2c32adf64c5d1..699b2dbaf75b2e44b7bcabab7fbfecd00bf7d5b4 100644 (file)
@@ -2995,18 +2995,15 @@ static int btusb_probe(struct usb_interface *intf,
                err = usb_set_interface(data->udev, 0, 0);
                if (err < 0) {
                        BT_ERR("failed to set interface 0, alt 0 %d", err);
-                       hci_free_dev(hdev);
-                       return err;
+                       goto out_free_dev;
                }
        }
 
        if (data->isoc) {
                err = usb_driver_claim_interface(&btusb_driver,
                                                 data->isoc, data);
-               if (err < 0) {
-                       hci_free_dev(hdev);
-                       return err;
-               }
+               if (err < 0)
+                       goto out_free_dev;
        }
 
 #ifdef CONFIG_BT_HCIBTUSB_BCM
@@ -3020,14 +3017,16 @@ static int btusb_probe(struct usb_interface *intf,
 #endif
 
        err = hci_register_dev(hdev);
-       if (err < 0) {
-               hci_free_dev(hdev);
-               return err;
-       }
+       if (err < 0)
+               goto out_free_dev;
 
        usb_set_intfdata(intf, data);
 
        return 0;
+
+out_free_dev:
+       hci_free_dev(hdev);
+       return err;
 }
 
 static void btusb_disconnect(struct usb_interface *intf)