Browse Source

Bugfix: cointerra: Check ep is open before trying to talk to it (crash at init failure)

Luke Dashjr 11 years ago
parent
commit
727d22132e
1 changed files with 8 additions and 5 deletions
  1. 8 5
      driver-cointerra.c

+ 8 - 5
driver-cointerra.c

@@ -220,11 +220,14 @@ static void cta_close(struct cgpu_info *cointerra)
 {
 	struct cointerra_info *info = cointerra->device_data;
 
-	/* Open does the same reset init followed by response as is required to
-	 * close the device. */
-	if (!cta_open(info->ep, cointerra->dev_repr, info)) {
-		applog(LOG_INFO, "%s %d: Reset on close failed", cointerra->drv->name,
-			cointerra->device_id);
+	if (info->ep)
+	{
+		/* Open does the same reset init followed by response as is required to
+		 * close the device. */
+		if (!cta_open(info->ep, cointerra->dev_repr, info)) {
+			applog(LOG_INFO, "%s %d: Reset on close failed", cointerra->drv->name,
+				cointerra->device_id);
+		}
 	}
 
 	mutex_destroy(&info->lock);