Commit 028da16bf804d5bdebaffa8a6e47ae94b6fa3d85

Kano 2013-01-23T22:13:42

usbutils free found if not used

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/usbutils.c b/usbutils.c
index 035e562..9eab1e1 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -1073,10 +1073,13 @@ void usb_detect(struct device_drv *drv, bool (*device_detect)(struct libusb_devi
 
 	for (i = 0; i < count; i++) {
 		found = usb_check(drv, list[i]);
-		if (found) {
-			if (cgminer_usb_lock(drv, list[i]) == true)
+		if (found != NULL) {
+			if (cgminer_usb_lock(drv, list[i]) == false)
+				free(found);
+			else {
 				if (!device_detect(list[i], found))
 					cgminer_usb_unlock(drv, list[i]);
+			}
 		}
 	}