Re: [hwmon PATCH v2 7/8] hwmon: (adt7470) Fix divide-by-zero TOCTOU crash in fan speed read

Guenter Roeck <[email protected]> Mon, 27 Jul 2026 17:58:17 -0700
Newsgroups org.kernel.vger.linux-hwmon,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Mon, Jul 27, 2026 at 09:22:23PM -0300, Luiz Angelo Daros de Luca wrote:
> If the fan data becomes 0 between the FAN_DATA_VALID() check and the
> FAN_PERIOD_TO_RPM() conversion, it will result in a divide-by-zero crash
> due to a race with a concurrent update of the cached fan value.
> 
> Fix a TOCTOU issue by reading fan data once.
> 
> Reported-by: [email protected]
> Closes: https://lore.kernel.org/r/[email protected]/
> Fixes: fc958a61ff6d ("hwmon: (adt7470) Convert to devm_hwmon_device_register_with_info API")
> Signed-off-by: Luiz Angelo Daros de Luca <[email protected]>

Applied.

Thanks,
Guenter