Commit 19d0efd7c0a51f3474ed3fc5007fc46cac2189cd

Con Kolivas 2014-02-23T20:31:04

The list_for_each_cgpu macro will dereference when there are no mining threads yet.

diff --git a/driver-hashfast.c b/driver-hashfast.c
index 33ad493..b8c5efa 100644
--- a/driver-hashfast.c
+++ b/driver-hashfast.c
@@ -566,9 +566,14 @@ static bool hfa_detect_common(struct cgpu_info *hashfast)
 		return true;
 
 	/* See if we can find a zombie instance of the same device */
-	list_for_each_cgpu(i, cgpu) {
+	for (i = 0; i < mining_threads; i++) {
 		struct hashfast_info *cinfo;
 
+		cgpu = mining_thr[i]->cgpu;
+		if (!cgpu)
+			continue;
+		if (cgpu == hashfast)
+			continue;
 		if (cgpu->drv->drv_id != DRIVER_hashfast)
 			continue;
 		if (!cgpu->usbinfo.nodev)
diff --git a/miner.h b/miner.h
index a4e843b..0f70491 100644
--- a/miner.h
+++ b/miner.h
@@ -288,10 +288,6 @@ struct strategies {
 
 struct cgpu_info;
 
-#define list_for_each_cgpu(thri, cgpu0) \
-	for (thri = 0, cgpu0 = mining_thr[thri]->cgpu; thri < mining_threads; \
-		thri++, cgpu0 = mining_thr[thri]->cgpu)
-
 extern void blank_get_statline_before(char *buf, size_t bufsiz, struct cgpu_info __maybe_unused *cgpu);
 
 struct api_data;