Skip to contentSkip to conversation

fix SCSI compile-time divide-by-zero with HZ < 100

PATCH New David Brownell 1 participant 1 message May 31, 2006 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix SCSI compile-time divide-by-zero with HZ < 100

This is the quickie patch, but someone might care to make the USER_HZ-coupled value scale for HZ=64 etc.

This fixes a compiler-reported divide-by-zero when HZ < 100.

block/scsi_ioctl.c +1 -1
@@ -63,7 +63,7 @@ static int scsi_get_bus(request_queue_t 
 
 static int sg_get_timeout(request_queue_t *q)
 {
-	return q->sg_timeout / (HZ / USER_HZ);
+	return q->sg_timeout / max(1,(HZ / USER_HZ));
 }
 
 static int sg_set_timeout(request_queue_t *q, int __user *p)