Browse Source

Bugfix: DevAPI: Free work when preparing it fails

Luke Dashjr 13 years ago
parent
commit
f73aa2fe17
1 changed files with 3 additions and 0 deletions
  1. 3 0
      deviceapi.c

+ 3 - 0
deviceapi.c

@@ -130,7 +130,10 @@ struct work *get_and_prepare_work(struct thr_info *thr)
 	struct work *work;
 	
 	work = get_work(thr);
+	if (!work)
+		return NULL;
 	if (api->prepare_work && !api->prepare_work(thr, work)) {
+		free_work(work);
 		applog(LOG_ERR, "%"PRIpreprv": Work prepare failed, disabling!", proc->proc_repr);
 		proc->deven = DEV_RECOVER_ERR;
 		return NULL;