Commit b2106b3aed398e92aeab63c931b30d608aafb1a8

Con Kolivas 2013-04-06T11:18:21

Free avalon->works in the event we call avalon_prepare on failure to initialise.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/driver-avalon.c b/driver-avalon.c
index 973b175..d0087b7 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -645,10 +645,14 @@ static bool avalon_prepare(struct thr_info *thr)
 	struct avalon_info *info = avalon_infos[avalon->device_id];
 	struct timeval now;
 
+	free(avalon->works);
 	avalon->works = calloc(info->miner_count * sizeof(struct work *), 4);
 	if (!avalon->works)
 		quit(1, "Failed to calloc avalon works in avalon_prepare");
-	__avalon_init(avalon);
+	if (avalon->device_fd == -1)
+		avalon_init(avalon);
+	else
+		__avalon_init(avalon);
 
 	gettimeofday(&now, NULL);
 	get_datestamp(avalon->init, &now);