Browse Source

Bugfix: drillbit: Avoid 9-byte memory leak for already-claimed devices

Luke Dashjr 11 years ago
parent
commit
b98ffb5fe7
1 changed files with 3 additions and 3 deletions
  1. 3 3
      driver-drillbit.c

+ 3 - 3
driver-drillbit.c

@@ -121,9 +121,6 @@ err:
 		// Production firmware Thumbs don't set any capability bits, so fill in the EXT_CLOCK one
 		caps |= DBC_EXT_CLOCK;
 	
-	char *serno = malloc(9);
-	snprintf(serno, 9, "%08lx", serialno);
-	
 	if (chips > 0x100)
 	{
 		applog(LOG_WARNING, "%s: %s: %u chips reported, but driver only supports up to 256",
@@ -134,6 +131,9 @@ err:
 	if (serial_claim_v(devpath, &drillbit_drv))
 		return false;
 	
+	char *serno = malloc(9);
+	snprintf(serno, 9, "%08lx", serialno);
+	
 	struct cgpu_info * const cgpu = malloc(sizeof(*cgpu));
 	*cgpu = (struct cgpu_info){
 		.drv = &drillbit_drv,