lkml.org 
[lkml]   [2005]   [Sep]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH 1/2] HPET: disallow zero interrupt frequency
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 <clemens@ladisch.de>
--- 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;
}
\
 
 \ /
  Last update: 2005-09-28 08:54    [W:0.116 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site