Kerneld woes

John Paul Morrison (jmorriso@bogomips.com)
Sat, 11 May 96 13:11 PDT


Newsgroups: linux.dev.kernel
Path: jmorriso
From: jmorriso@bogomips.com (John Paul Morrison)
Subject: divide by zero error in kernel
Organization: BogoMIPS Research Labs
Message-ID: <1996May11.201131.14644@bogomips.com>
Date: Sat, 11 May 1996 20:11:31 GMT

I found a place where the kernel divides by zero - this prints some
messy notices in the logs but does not panic or hanf the system

this patch shows where the bug is, and prevents the divide by zero,
but it should really be fixed some other way. I think a zero argument
is supposed to be handled specially, but I'm not familiar with the code.

I uncovered this problem with a program that generates simple PC
speaker sounds using console ioctls. The program works fine in Linux
1.2.13, so something must have changed in the 1.3 console ioctl argument
handling.

(patch relative to 1.3.98)

--- linux/drivers/char/vt.c.old Fri May 3 22:52:43 1996
+++ linux/drivers/char/vt.c Sat May 11 13:01:35 1996
@@ -236,6 +236,7 @@
* If the time is zero, turn off sound ourselves.
*/
ticks = HZ * ((arg >> 16) & 0xffff) / 1000;
+ if (arg & 0xffff == 0 ) arg |= 1; /* jp: huh? */
count = ticks ? (1193180 / (arg & 0xffff)) : 0;
kd_mksound(count, ticks);
return 0;

-- 
---------------------------------------------------------------------------
BogoMIPS Research Labs  --  bogosity research & simulation  --  VE7JPM  -- 
  jmorriso@bogomips.com  ve7jpm@ve7jpm.ampr.org  jmorriso@ve7ubc.ampr.org
---------------------------------------------------------------------------