]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
hwmon: (emc2103) Add locking to avoid TOCTOU
authorGui-Dong Han <hanguidong02@gmail.com>
Mon, 24 Nov 2025 16:55:08 +0000 (00:55 +0800)
committerGuenter Roeck <linux@roeck-us.net>
Mon, 24 Nov 2025 19:45:16 +0000 (11:45 -0800)
commit4faaa77d6b32347ea6af74d5fd2f34c3922aeee6
tree8e6531d3ab615b82f07eed6405b21f3960237023
parentedbce49ea6535a56aac3a5e211cf7af873d7221d
hwmon: (emc2103) Add locking to avoid TOCTOU

The functions fan1_input_show and fan1_target_show check shared data for
zero 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@mail.gmail.com/
Signed-off-by: Gui-Dong Han <hanguidong02@gmail.com>
Link: https://lore.kernel.org/r/20251124165508.4667-1-hanguidong02@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/emc2103.c