From: OpenOCD-Gerrit <ope...@us...> - 2021-03-19 22:02:54
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via f09aa77c0ca6f9f926be8a4508e9de58284052f6 (commit) from 08c7b904c38b97f9de72a19196b295652f051268 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit f09aa77c0ca6f9f926be8a4508e9de58284052f6 Author: Oleksij Rempel <o.r...@pe...> 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 <o.r...@pe...> Reviewed-on: http://openocd.zylin.com/6115 Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/src/jtag/drivers/usb_blaster/ublast2_access_libusb.c b/src/jtag/drivers/usb_blaster/ublast2_access_libusb.c index 82dc95071..4dec89b11 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) ----------------------------------------------------------------------- Summary of changes: src/jtag/drivers/usb_blaster/ublast2_access_libusb.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) hooks/post-receive -- Main OpenOCD repository |