From: "Jan Kundrát" <jan.kundrat@cesnet.cz>
To: "Václav Kubernát" <kubernat@cesnet.cz>
Cc: Jean Delvare <jdelvare@suse.com>,
Guenter Roeck <linux@roeck-us.net>,
Jonathan Corbet <corbet@lwn.net>, <linux-hwmon@vger.kernel.org>,
<linux-doc@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/7] hwmon: (max31790) Allow setting pulses
Date: Fri, 05 Mar 2021 13:08:26 +0100 [thread overview]
Message-ID: <ad1c3054-e9a2-4299-aeed-94e36d6d3d12@cesnet.cz> (raw)
In-Reply-To: <20210304105830.507176-3-kubernat@cesnet.cz>
> @@ -285,6 +295,9 @@ static int max31790_write_fan(struct device
> *dev, u32 attr, int channel,
> MAX31790_REG_FAN_CONFIG(channel),
> data->fan_config[channel]);
> break;
> + case hwmon_fan_pulses:
> + data->pulses[channel] = val;
> + break;
This needs input validation, otherwise it's possible to write 0 in there
and you get a division-by-zero in the kernel context:
[102109.999968] Division by zero in kernel.
[102110.003917] CPU: 1 PID: 27590 Comm: cat Not tainted 5.9.3-cla-cfb #42
[102110.010462] Hardware name: Marvell Armada 380/385 (Device Tree)
[102110.016497] [<c010f16c>] (unwind_backtrace) from [<c010ae40>]
(show_stack+0x10/0x14)
[102110.024355] [<c010ae40>] (show_stack) from [<c083ba30>]
(dump_stack+0x94/0xa8)
[102110.031689] [<c083ba30>] (dump_stack) from [<c083a3fc>]
(Ldiv0+0x8/0x2c)
[102110.038499] [<c083a3fc>] (Ldiv0) from [<c064c1ac>]
(max31790_read+0x174/0x204)
[102110.045836] [<c064c1ac>] (max31790_read) from [<c0646fdc>]
(hwmon_attr_show+0x44/0x138)
...
A similar error can also happen when setting the fan speed to 0 RPM.
That's, however, not an error caused by this patch series AFAIK. I *think*
that RPM_TO_REG should be changed to check if `rpm` is 0, and if so, set
the register directly to the maximal value of 0x7ff (in another patch).
With kind regards,
Jan
next prev parent reply other threads:[~2021-03-05 12:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-04 10:58 [PATCH 1/7] hwmon: (max31790) Rework to use regmap Václav Kubernát
2021-03-04 10:58 ` [PATCH 2/7] hwmon: (max31790) Fix and split pwm*_enable Václav Kubernát
2021-03-04 10:58 ` [PATCH 3/7] hwmon: (max31790) Allow setting pulses Václav Kubernát
2021-03-05 12:08 ` Jan Kundrát [this message]
2021-03-08 9:31 ` Václav Kubernát
2021-03-04 10:58 ` [PATCH 4/7] hwmon: (max31790) Show 0 RPM/fault when input disabled Václav Kubernát
2021-03-04 10:58 ` [PATCH 5/7] hwmon: (max31790) Refactor HWMON_CHANNEL_INFO Václav Kubernát
2021-03-04 10:58 ` [PATCH 6/7] hwmon: (max31790) Allow setting fan*_div Václav Kubernát
2021-03-04 10:58 ` [PATCH 7/7] hwmon: (max31790) Update documentation Václav Kubernát
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=ad1c3054-e9a2-4299-aeed-94e36d6d3d12@cesnet.cz \
--to=jan.kundrat@cesnet.cz \
--cc=corbet@lwn.net \
--cc=jdelvare@suse.com \
--cc=kubernat@cesnet.cz \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox