From: Clemens Ladisch Date: Sun, 30 Oct 2005 23:03:29 +0000 (-0800) Subject: [PATCH] hpet: disallow zero interrupt frequency X-Git-Tag: v3.12-rc1~40274^2~72^2~28 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9090e6db87e3bdb2a2c187ebc0f9175a9f9e5c6f;p=kernel%2Fkernel-generic.git [PATCH] hpet: disallow zero interrupt frequency Disallow setting an interrupt frequency of zero (which would result in a division by zero), and disallow enabling the interrupt when the frequency hasn't yet been set (which would use an interrupt period of zero). Signed-off-by: Clemens Ladisch Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c index c055bb6..b619ca5 100644 --- a/drivers/char/hpet.c +++ b/drivers/char/hpet.c @@ -364,6 +364,9 @@ static int hpet_ioctl_ieon(struct hpet_dev *devp) hpet = devp->hd_hpet; hpetp = devp->hd_hpets; + if (!devp->hd_ireqfreq) + return -EIO; + v = readq(&timer->hpet_config); spin_lock_irq(&hpet_lock); @@ -516,7 +519,7 @@ hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg, int kernel) break; } - if (arg & (arg - 1)) { + if (!arg || (arg & (arg - 1))) { err = -EINVAL; break; }