Commit 013c93f743a9e3ce4145c2047a28ac5e59e10f81

Con Kolivas 2013-11-13T20:01:41

Initialise the stgd lock mutex earlier to prevent dereferences when pool testing occurs before it.

diff --git a/cgminer.c b/cgminer.c
index 8dd1d7e..b2f1fb1 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -7780,6 +7780,13 @@ int main(int argc, char *argv[])
 	if (unlikely(pthread_cond_init(&gws_cond, NULL)))
 		quit(1, "Failed to pthread_cond_init gws_cond");
 
+	/* Create a unique get work queue */
+	getq = tq_new();
+	if (!getq)
+		quit(1, "Failed to create getq");
+	/* We use the getq mutex as the staged lock */
+	stgd_lock = &getq->mutex;
+
 	initialise_usb();
 
 	snprintf(packagename, sizeof(packagename), "%s %s", PACKAGE, VERSION);
@@ -8006,13 +8013,6 @@ int main(int argc, char *argv[])
 			quit(1, "Failed to calloc mining_thr[%d]", i);
 	}
 
-	/* Create a unique get work queue */
-	getq = tq_new();
-	if (!getq)
-		quit(1, "Failed to create getq");
-	/* We use the getq mutex as the staged lock */
-	stgd_lock = &getq->mutex;
-
 	if (opt_benchmark)
 		goto begin_bench;