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

From: Guenter Roeck

Date: Mon Jul 27 2026 - 21:04:41 EST


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: sashiko-bot@xxxxxxxxxx
> Closes: https://lore.kernel.org/r/20260727034929.E29B71F000E9@xxxxxxxxxxxxxxx/
> Fixes: fc958a61ff6d ("hwmon: (adt7470) Convert to devm_hwmon_device_register_with_info API")
> Signed-off-by: Luiz Angelo Daros de Luca <luizluca@xxxxxxxxx>

Applied.

Thanks,
Guenter