Re: [PATCH 1/2] HPET: disallow zero interrupt frequency

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Bob Picco wrote:
> > -	if (arg & (arg - 1)) {
> > +	if (arg < 1 || (arg & (arg - 1))) {
>
> Well it seems like what you want is:
>
> 	if (!arg || (arg & (arg - 1))) {

Yes, it's the same.  Here's the new patch:

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 <[email protected]>
--- linux-2.6.13.orig/drivers/char/hpet.c	2005-09-22 10:56:23.000000000 +0200
+++ linux-2.6.13/drivers/char/hpet.c	2005-09-25 19:02:02.000000000 +0200
@@ -365,6 +365,9 @@ static int hpet_ioctl_ieon(struct hpet_d
 	hpet = devp->hd_hpet;
 	hpetp = devp->hd_hpets;
 
+	if (!devp->hd_ireqfreq)
+		return -EIO;
+
 	v = readq(&timer->hpet_config);
 	spin_lock_irq(&hpet_lock);
 
@@ -517,7 +520,7 @@ hpet_ioctl_common(struct hpet_dev *devp,
 			break;
 		}
 
-		if (arg & (arg - 1)) {
+		if (!arg || (arg & (arg - 1))) {
 			err = -EINVAL;
 			break;
 		}

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux