Make sure cgpu exists in the restart threads loop in cases of hotplug etc.
diff --git a/cgminer.c b/cgminer.c
index 42ee76d..09fd008 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -4007,6 +4007,8 @@ static void restart_threads(void)
rd_lock(&mining_thr_lock);
for (i = 0; i < mining_threads; i++) {
cgpu = mining_thr[i]->cgpu;
+ if (unlikely(!cgpu))
+ continue;
mining_thr[i]->work_restart = true;
flush_queue(cgpu);
cgpu->drv->flush_work(cgpu);