From: Antonio Ospite <ao2@ao2.it>
Date: Mon, 20 Apr 2015 15:19:10 +0000 (+0200)
Subject: am7xxx: release the interface when needed in open_device()
X-Git-Tag: v0.1.6~26
X-Git-Url: https://git.ao2.it/libam7xxx.git/commitdiff_plain/9afe9f1293358f92483fba4c7052517e29f831aa?hp=2bb4878fcc5ccc152634087f0aa13ab1eec56de0

am7xxx: release the interface when needed in open_device()

Release the interface when bailing out of open_device() after the
interface has been claimed.
---

diff --git a/src/am7xxx.c b/src/am7xxx.c
index b00a6be..2ba9561 100644
--- a/src/am7xxx.c
+++ b/src/am7xxx.c
@@ -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;