]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
hwmon: (lm87) Convert macros to functions to avoid TOCTOU
authorGui-Dong Han <hanguidong02@gmail.com>
Wed, 26 Nov 2025 11:35:42 +0000 (19:35 +0800)
committerGuenter Roeck <linux@roeck-us.net>
Wed, 26 Nov 2025 15:47:25 +0000 (07:47 -0800)
commitbe89cf786d36f44d7765c572296fc9299afa428c
tree16384935b562a49ca5b33b97da89e1b8f404f456
parentfe5dbe3110c559a2e6d13f114238621d89cb24f8
hwmon: (lm87) Convert macros to functions to avoid TOCTOU

The macro FAN_FROM_REG evaluates its arguments multiple times. When used
in lockless contexts involving shared driver data, this causes
Time-of-Check to Time-of-Use (TOCTOU) race conditions.

Convert the macro to a static function. This guarantees that arguments
are evaluated only once (pass-by-value), preventing the race
conditions.

Adhere to the principle of minimal changes by only converting macros
that evaluate arguments multiple times and are used in lockless
contexts.

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/20251126113542.9968-1-hanguidong02@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/lm87.c