Re: [PATCH] hwmon: (adm1029) Add locking to avoid TOCTOU

From: Guenter Roeck

Date: Wed Nov 26 2025 - 10:49:28 EST


On Wed, Nov 26, 2025 at 07:40:46PM +0800, Gui-Dong Han wrote:
> The function fan_show checks shared data for zero or invalid values
> before using it as a divisor. These accesses are currently lockless. If
> the data changes to zero between the check and the division, it causes a
> divide-by-zero error.
>
> Explicitly acquire the update lock around these checks and calculations
> to ensure the data remains stable, preventing Time-of-Check to
> Time-of-Use (TOCTOU) race conditions.
>
> Link: https://lore.kernel.org/all/CALbr=LYJ_ehtp53HXEVkSpYoub+XYSTU8Rg=o1xxMJ8=5z8B-g@xxxxxxxxxxxxxx/
> Signed-off-by: Gui-Dong Han <hanguidong02@xxxxxxxxx>

Applied.

Thanks,
Guenter