From: roger <roger@hiddenengine.co.uk>
To: kernel-janitors@vger.kernel.org
Subject: Re: [patch] hwmon: prevent some divide by zeros in FAN_TO_REG()
Date: Thu, 05 Dec 2013 11:07:51 +0000 [thread overview]
Message-ID: <db3f06d585a4dea3efe200f9e2f5fca6@mailserver.hiddenengine.co.uk> (raw)
On , Dan Carpenter wrote:
> It's not enough to just test if "rpm" is zero, the "rpm * div"
> operation
> could overflow and that could also lead to a divide by zero.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c
> index 0e7017841f7d..923c18034a5f 100644
> --- a/drivers/hwmon/vt8231.c
> +++ b/drivers/hwmon/vt8231.c
> @@ -145,7 +145,7 @@ static const u8 regtempmin[] = { 0x3a, 0x3e, 0x2c,
> 0x2e, 0x30, 0x32 };
> */
> static inline u8 FAN_TO_REG(long rpm, int div)
> {
> - if (rpm = 0)
> + if (rpm * div = 0)
> return 0;
> return clamp_val(1310720 / (rpm * div), 1, 255);
> }
Seems a reasonable improvement to me, so ACK'd.
> diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c
> index 6cf6bff79003..fc4578195674 100644
SNIP
> return 255;
> return clamp_val((1350000 + rpm * div / 2) / (rpm * div), 1, 254);
> }
- Roger
WARNING: multiple messages have this Message-ID (diff)
From: roger <roger@hiddenengine.co.uk>
To: kernel-janitors@vger.kernel.org
Subject: Re: [lm-sensors] [patch] hwmon: prevent some divide b
Date: Thu, 05 Dec 2013 11:07:51 +0000 [thread overview]
Message-ID: <db3f06d585a4dea3efe200f9e2f5fca6@mailserver.hiddenengine.co.uk> (raw)
On , Dan Carpenter wrote:
> It's not enough to just test if "rpm" is zero, the "rpm * div"
> operation
> could overflow and that could also lead to a divide by zero.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c
> index 0e7017841f7d..923c18034a5f 100644
> --- a/drivers/hwmon/vt8231.c
> +++ b/drivers/hwmon/vt8231.c
> @@ -145,7 +145,7 @@ static const u8 regtempmin[] = { 0x3a, 0x3e, 0x2c,
> 0x2e, 0x30, 0x32 };
> */
> static inline u8 FAN_TO_REG(long rpm, int div)
> {
> - if (rpm = 0)
> + if (rpm * div = 0)
> return 0;
> return clamp_val(1310720 / (rpm * div), 1, 255);
> }
Seems a reasonable improvement to me, so ACK'd.
> diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c
> index 6cf6bff79003..fc4578195674 100644
SNIP
> return 255;
> return clamp_val((1350000 + rpm * div / 2) / (rpm * div), 1, 254);
> }
- Roger
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
next reply other threads:[~2013-12-05 11:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-05 11:07 roger [this message]
2013-12-05 11:07 ` [lm-sensors] [patch] hwmon: prevent some divide b roger
-- strict thread matches above, loose matches on Subject: below --
2013-12-05 10:58 [patch] hwmon: prevent some divide by zeros in FAN_TO_REG() Dan Carpenter
2013-12-05 12:06 ` Jean Delvare
2013-12-05 12:59 ` Dan Carpenter
2013-12-05 13:13 ` Dan Carpenter
2013-12-05 14:29 ` Jean Delvare
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=db3f06d585a4dea3efe200f9e2f5fca6@mailserver.hiddenengine.co.uk \
--to=roger@hiddenengine.co.uk \
--cc=kernel-janitors@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.