Skip to content

Commit

Permalink
[PATCH] hpet: disallow zero interrupt frequency
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Clemens Ladisch authored and Linus Torvalds committed Oct 31, 2005
1 parent 874ec33 commit 9090e6d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/char/hpet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 9090e6d

Please sign in to comment.