Commit 749fa78d8a882cdfaec8813f0cf64ed63f5642d2

Kano 2013-06-10T15:39:44

tidy up free in device detect functions

diff --git a/driver-avalon.c b/driver-avalon.c
index 610483b..35307c4 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -653,11 +653,11 @@ unshin:
 
 shin:
 
-	if (avalon->device_data)
-		free(avalon->device_data);
+	free(avalon->device_data);
+	avalon->device_data = NULL;
 
-	if (avalon->device_path)
-		free(avalon->device_path);
+	free(avalon->device_path);
+	avalon->device_path = NULL;
 
 	avalon = usb_free_cgpu(avalon);
 
diff --git a/driver-bflsc.c b/driver-bflsc.c
index 501fa56..52ba312 100644
--- a/driver-bflsc.c
+++ b/driver-bflsc.c
@@ -966,13 +966,15 @@ unshin:
 shin:
 
 	free(bflsc->device_path);
+	bflsc->device_path = NULL;
+
 	free(bflsc->device_data);
+	bflsc->device_data = NULL;
 
-	if (bflsc->name != blank)
+	if (bflsc->name != blank) {
 		free(bflsc->name);
-
-	if (bflsc->drv->copy)
-		free(bflsc->drv);
+		bflsc->name = NULL;
+	}
 
 	bflsc = usb_free_cgpu(bflsc);
 
diff --git a/driver-bitforce.c b/driver-bitforce.c
index 7e2f1d1..de575cf 100644
--- a/driver-bitforce.c
+++ b/driver-bitforce.c
@@ -287,12 +287,12 @@ unshin:
 shin:
 
 	free(bitforce->device_path);
+	bitforce->device_path = NULL;
 
-	if (bitforce->name != blank)
+	if (bitforce->name != blank) {
 		free(bitforce->name);
-
-	if (bitforce->drv->copy)
-		free(bitforce->drv);
+		bitforce->name = NULL;
+	}
 
 	bitforce = usb_free_cgpu(bitforce);
 
diff --git a/driver-icarus.c b/driver-icarus.c
index d854101..4b06c53 100644
--- a/driver-icarus.c
+++ b/driver-icarus.c
@@ -843,6 +843,7 @@ unshin:
 	usb_uninit(icarus);
 
 	free(icarus->device_path);
+	icarus->device_path = NULL;
 
 shin:
 
diff --git a/driver-modminer.c b/driver-modminer.c
index 5df0560..f537e7d 100644
--- a/driver-modminer.c
+++ b/driver-modminer.c
@@ -210,6 +210,7 @@ static bool modminer_detect_one(struct libusb_device *dev, struct usb_find_devic
 
 		if (!add_cgpu(tmp)) {
 			free(tmp->device_path);
+			tmp->device_path = NULL;
 			tmp = usb_free_cgpu(tmp);
 			goto unshin;
 		}
@@ -228,8 +229,10 @@ unshin:
 		usb_uninit(modminer);
 
 shin:
-	if (!added)
+	if (!added) {
 		free(modminer->modminer_mutex);
+		modminer->modminer_mutex = NULL;
+	}
 
 	modminer = usb_free_cgpu(modminer);
 
@@ -1096,6 +1099,7 @@ static void modminer_hw_error(struct thr_info *thr)
 static void modminer_fpga_shutdown(struct thr_info *thr)
 {
 	free(thr->cgpu_data);
+	thr->cgpu_data = NULL;
 }
 
 static char *modminer_set_device(struct cgpu_info *modminer, char *option, char *setting, char *replybuf)