am7xxx_mode_switch: release interface only if claimed
authorAntonio Ospite <ospite@studenti.unina.it>
Sat, 23 Mar 2013 22:03:48 +0000 (23:03 +0100)
committerAntonio Ospite <ospite@studenti.unina.it>
Sat, 23 Mar 2013 22:03:48 +0000 (23:03 +0100)
examples/am7xxx_mode_switch.c

index 7509981..572586c 100644 (file)
@@ -81,16 +81,16 @@ int main(void)
        if (ret != 0 || (unsigned int)transferred != len) {
                fprintf(stderr, "ret: %d\ttransferred: %d (expected %u)\n",
                      ret, transferred, len);
        if (ret != 0 || (unsigned int)transferred != len) {
                fprintf(stderr, "ret: %d\ttransferred: %d (expected %u)\n",
                      ret, transferred, len);
-               goto out_libusb_close;
+               goto out_libusb_release_interface;
        }
 
        fprintf(stderr, "OK, command sent!\n");
 
        }
 
        fprintf(stderr, "OK, command sent!\n");
 
-out_libusb_close:
+out_libusb_release_interface:
        libusb_release_interface(usb_device, AM7XXX_STORAGE_INTERFACE);
        libusb_release_interface(usb_device, AM7XXX_STORAGE_INTERFACE);
+out_libusb_close:
        libusb_close(usb_device);
        usb_device = NULL;
        libusb_close(usb_device);
        usb_device = NULL;
-
 out:
        libusb_exit(NULL);
        return ret;
 out:
        libusb_exit(NULL);
        return ret;