Skip to content

Commit

Permalink
it87: Prevent overflow on fan clock divider write
Browse files Browse the repository at this point in the history
it87: Prevent overflow on fan clock divider write

The highest possible clock divider for fan1 and fan2 is 128.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Jean Delvare authored and gregkh committed Sep 28, 2006
1 parent 9060f8b commit b9e349f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/hwmon/it87.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ static inline u16 FAN16_TO_REG(long rpm)
static int DIV_TO_REG(int val)
{
int answer = 0;
while ((val >>= 1) != 0)
while (answer < 7 && (val >>= 1))
answer++;
return answer;
}
Expand Down Expand Up @@ -563,7 +563,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,

struct i2c_client *client = to_i2c_client(dev);
struct it87_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
unsigned long val = simple_strtoul(buf, NULL, 10);
int i, min[3];
u8 old;

Expand Down

0 comments on commit b9e349f

Please sign in to comment.