Commit b2cef1148066591a81401786f2cad573d1a923a1

Con Kolivas 2012-06-25T06:18:27

Merge pull request #235 from kanoi/master icarus - must allows allocate memory for icarus_info

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/driver-icarus.c b/driver-icarus.c
index 4d8ac53..442eb9d 100644
--- a/driver-icarus.c
+++ b/driver-icarus.c
@@ -426,11 +426,10 @@ static bool icarus_detect_one(const char *devpath)
 	applog(LOG_INFO, "Found Icarus at %s, mark as %d",
 		devpath, icarus->device_id);
 
-	if (icarus_info[icarus->device_id] == NULL) {
-		icarus_info[icarus->device_id] = (struct ICARUS_INFO *)malloc(sizeof(struct ICARUS_INFO));
-		if (unlikely(!(icarus_info[icarus->device_id])))
-			quit(1, "Failed to malloc ICARUS_INFO");
-	}
+	// Since we are adding a new device on the end it needs to always be allocated
+	icarus_info[icarus->device_id] = (struct ICARUS_INFO *)malloc(sizeof(struct ICARUS_INFO));
+	if (unlikely(!(icarus_info[icarus->device_id])))
+		quit(1, "Failed to malloc ICARUS_INFO");
 
 	info = icarus_info[icarus->device_id];