[PATCH] hpet: disallow zero interrupt frequency
authorClemens Ladisch <clemens@ladisch.de>
Sun, 30 Oct 2005 23:03:29 +0000 (15:03 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 31 Oct 2005 01:37:29 +0000 (17:37 -0800)
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 <clemens@ladisch.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/char/hpet.c

index c055bb630ffcda9e882923c2256cb6137dfb491d..b619ca5eaf8c52cfb0c77b550e99fb91caaa1fc9 100644 (file)
@@ -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;
                }