From 11a36418b2accc0c299482521f23e4a0874cb8f7 Mon Sep 17 00:00:00 2001 From: Kano Date: Tue, 24 Sep 2013 12:46:09 +1000 Subject: [PATCH] klondike - avoid division by zero if maxcount is unexpectedly zero --- driver-klondike.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/driver-klondike.c b/driver-klondike.c index 389444af..b3ffe37d 100644 --- a/driver-klondike.c +++ b/driver-klondike.c @@ -537,7 +537,8 @@ static int64_t klondike_scanwork(struct thr_info *thr) newhashdev += klninfo->status[dev].maxcount; // hash counter wrapped newhashdev += klninfo->status[dev].hashcount - klninfo->devinfo[dev].lasthashcount; klninfo->devinfo[dev].lasthashcount = klninfo->status[dev].hashcount; - klninfo->hashcount += (newhashdev << 32) / klninfo->status[dev].maxcount; + if (klninfo->status[dev].maxcount != 0) + klninfo->hashcount += (newhashdev << 32) / klninfo->status[dev].maxcount; // todo: check stats for critical conditions }