From: Uwe Bonnes Date: Sat, 10 Dec 2011 17:08:06 +0000 (+0100) Subject: Fix leakage pathes for V1 X-Git-Url: https://git.gag.com/?p=fw%2Fstlink;a=commitdiff_plain;h=48b604040a78177c9695396710d75d0194935228 Fix leakage pathes for V1 --- diff --git a/src/stlink-sg.c b/src/stlink-sg.c index 50c0db5..394417b 100644 --- a/src/stlink-sg.c +++ b/src/stlink-sg.c @@ -857,6 +857,7 @@ static stlink_t* stlink_open(const int verbose) { if (slsg->usb_handle == NULL) { WLOG("Failed to find an stlink v1 by VID:PID\n"); libusb_close(slsg->usb_handle); + libusb_exit(slsg->libusb_ctx); free(sl); free(slsg); return NULL; @@ -871,6 +872,7 @@ static stlink_t* stlink_open(const int verbose) { if (r < 0) { WLOG("libusb_detach_kernel_driver(() error %s\n", strerror(-r)); libusb_close(slsg->usb_handle); + libusb_exit(slsg->libusb_ctx); free(sl); free(slsg); return NULL; @@ -883,6 +885,7 @@ static stlink_t* stlink_open(const int verbose) { /* this may fail for a previous configured device */ WLOG("libusb_get_configuration()\n"); libusb_close(slsg->usb_handle); + libusb_exit(slsg->libusb_ctx); free(sl); free(slsg); return NULL; @@ -897,6 +900,7 @@ static stlink_t* stlink_open(const int verbose) { /* this may fail for a previous configured device */ WLOG("libusb_set_configuration() failed\n"); libusb_close(slsg->usb_handle); + libusb_exit(slsg->libusb_ctx); free(sl); free(slsg); return NULL; @@ -906,6 +910,7 @@ static stlink_t* stlink_open(const int verbose) { if (libusb_claim_interface(slsg->usb_handle, 0)) { WLOG("libusb_claim_interface() failed\n"); libusb_close(slsg->usb_handle); + libusb_exit(slsg->libusb_ctx); free(sl); free(slsg); return NULL;