Browse Source

Check return code from hashfast_get_header in reset and fail when appropriate.

Con Kolivas 12 years ago
parent
commit
775f2040e5
1 changed files with 11 additions and 1 deletions
  1. 11 1
      driver-hashfast.c

+ 11 - 1
driver-hashfast.c

@@ -210,8 +210,18 @@ static bool hashfast_reset(struct cgpu_info *hashfast, struct hashfast_info *inf
 		if (ret)
 			break;
 	}
-	if (!ret)
+	if (!ret) {
 		applog(LOG_WARNING, "HFA %d: OP_USB_INIT failed!", hashfast->device_id);
+		return false;
+	}
+	if (h->crc8 != hcrc) {
+		applog(LOG_WARNING, "HFA %d: OP_USB_INIT failed! CRC mismatch", hashfast->device_id);
+		return false;
+	}
+	if (h->operation_code != OP_USB_INIT) {
+		applog(LOG_WARNING, "HFA %d: OP_USB_INIT: Tossing packet, valid but unexpected type", hashfast->device_id);
+		return false;
+	}
 
 	return true;
 }