Browse Source

Bugfix: knc: Check that device actually has work queued, before trying to find the most recent one

Luke Dashjr 12 years ago
parent
commit
4ef0d1e2a6
1 changed files with 2 additions and 2 deletions
  1. 2 2
      driver-knc.c

+ 2 - 2
driver-knc.c

@@ -339,7 +339,7 @@ bool knc_queue_append(struct thr_info * const thr, struct work * const work)
 }
 
 #define HASH_LAST_ADDED(head, out)  \
-	(out = (ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail)))
+	(out = (head) ? (ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail)) : NULL)
 
 static
 void knc_queue_flush(struct thr_info * const thr)
@@ -358,7 +358,7 @@ void knc_queue_flush(struct thr_info * const thr)
 	thr->queue_full = false;
 	
 	HASH_LAST_ADDED(knc->devicework, work);
-	if (stale_work(work, true))
+	if (work && stale_work(work, true))
 	{
 		knc->need_flush = true;
 		timer_set_now(&thr->tv_poll);