From: sashiko-bot@kernel.org
To: "Shirong Zhao" <shxzhaosr@163.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH] hwmon: (emc2305) fix division by zero for a small tach reading
Date: Sat, 05 Dec 2026 01:30:24 +0000 [thread overview]
Message-ID: <sashiko-outbox-250897@kernel.org> (raw)
In-Reply-To: <20261205012416.100-1-shxzhaosr@163.com>
> emc2305_show_fan() guards the raw 16-bit tach register value with
> `if (ret <= 0)`, then shifts it right by EMC2305_TACH_REGS_UNUSE_BITS (3)
> before dividing:
>
> ret = ret >> EMC2305_TACH_REGS_UNUSE_BITS;
> ret = EMC2305_RPM_FACTOR / ret;
>
> A tach register value of 1..7 survives the first check but becomes 0
> after the shift, so the division is a divide by zero. The register value
> comes from the fan controller (the driver never writes it); reading the
> read-only fan1_input attribute of a faulty or emulated controller that
> reports 1..7 therefore crashes the kernel. Userspace only triggers the
> read; the zero divisor is device-provided.
>
> Re-check for zero after the shift.
>
> Fixes: 0d8400c5a2ce ("hwmon: (emc2305) add support for EMC2301/2/3/5 RPM-based PWM Fan Speed Controller.")
> Signed-off-by: Shirong Zhao <shxzhaosr@163.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205012416.100-1-shxzhaosr@163.com?part=1
next prev parent reply other threads:[~2026-12-05 1:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 1:24 [PATCH] hwmon: (emc2305) fix division by zero for a small tach reading Shirong Zhao
2026-12-05 1:30 ` sashiko-bot [this message]
2026-12-05 16:27 ` Guenter Roeck
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=sashiko-outbox-250897@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=shxzhaosr@163.com \
/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