tidy up free in device detect functions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
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)