am7xxx: release the interface when needed in open_device()
authorAntonio Ospite <ao2@ao2.it>
Mon, 20 Apr 2015 15:19:10 +0000 (17:19 +0200)
committerAntonio Ospite <ao2@ao2.it>
Mon, 20 Apr 2015 16:03:55 +0000 (18:03 +0200)
Release the interface when bailing out of open_device() after the
interface has been claimed.

src/am7xxx.c

index b00a6be..2ba9561 100644 (file)
@@ -784,18 +784,21 @@ static int open_device(am7xxx_context *ctx,
        if (ret < 0) {
                debug(ctx, "libusb_get_configuration after claim failed: %s\n",
                      libusb_error_name(ret));
-               goto out_libusb_close;
+               goto out_libusb_release_interface;
        }
 
        if (current_configuration != (*dev)->desc->configuration) {
                debug(ctx, "libusb configuration changed (expected: %hhu, current: %hhu\n",
                      (*dev)->desc->configuration, current_configuration);
                ret = -EINVAL;
-               goto out_libusb_close;
+               goto out_libusb_release_interface;
        }
 out:
        return ret;
 
+out_libusb_release_interface:
+       libusb_release_interface((*dev)->usb_device,
+                                (*dev)->desc->interface_number);
 out_libusb_close:
        libusb_close((*dev)->usb_device);
        (*dev)->usb_device = NULL;