This is an automated email from Gerrit.

Oleksij Rempel ([email protected]) just uploaded a new patch set to 
Gerrit, which you can find at http://openocd.zylin.com/6115

-- gerrit

commit 8fa9065463edbaf5795675901bf321247cc707ab
Author: Oleksij Rempel <[email protected]>
Date:   Thu Mar 18 18:47:35 2021 +0100

    drivers: USB Blaster II: close file and release USB device if firmware 
handling failed
    
    In case of some error, the USB device and firmware file are still
    claimed. Make sure refcounting is properly accounted for both cases.
    
    Change-Id: I933114f68e59280e58372c0941a0062fe96ab340
    Signed-off-by: Oleksij Rempel <[email protected]>

diff --git a/src/jtag/drivers/usb_blaster/ublast2_access_libusb.c 
b/src/jtag/drivers/usb_blaster/ublast2_access_libusb.c
index 82dc950..4dec89b 100644
--- a/src/jtag/drivers/usb_blaster/ublast2_access_libusb.c
+++ b/src/jtag/drivers/usb_blaster/ublast2_access_libusb.c
@@ -144,7 +144,7 @@ static int load_usb_blaster_firmware(struct 
libusb_device_handle *libusb_dev,
        int ret = image_open(&ublast2_firmware_image, low->firmware_path, 
"ihex");
        if (ret != ERROR_OK) {
                LOG_ERROR("Could not load firmware image");
-               return ret;
+               goto error_release_usb;
        }
 
        /** A host loader program must write 0x01 to the CPUCS register
@@ -172,7 +172,7 @@ static int load_usb_blaster_firmware(struct 
libusb_device_handle *libusb_dev,
                                                     &ublast2_firmware_image, 
i);
                if (ret != ERROR_OK) {
                        LOG_ERROR("Error while downloading the firmware");
-                       return ret;
+                       goto error_close_firmware;
                }
        }
 
@@ -187,8 +187,10 @@ static int load_usb_blaster_firmware(struct 
libusb_device_handle *libusb_dev,
                                     1,
                                     100);
 
+error_close_firmware:
        image_close(&ublast2_firmware_image);
 
+error_release_usb:
        /*
         * Release claimed interface. Most probably it is already disconnected
         * and re-enumerated as new devices after firmware upload, so we do
@@ -196,7 +198,7 @@ static int load_usb_blaster_firmware(struct 
libusb_device_handle *libusb_dev,
         */
        libusb_release_interface(libusb_dev, 0);
 
-       return ERROR_OK;
+       return ret;
 }
 
 static int ublast2_libusb_init(struct ublast_lowlevel *low)

-- 


_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to