]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
hwmon: (w83l786ng) Convert macros to functions to avoid TOCTOU
authorGui-Dong Han <hanguidong02@gmail.com>
Fri, 28 Nov 2025 12:38:16 +0000 (20:38 +0800)
committerGuenter Roeck <linux@roeck-us.net>
Fri, 28 Nov 2025 16:30:24 +0000 (08:30 -0800)
commit07272e883fc61574b8367d44de48917f622cdd83
treefd44ee146a3a778e13e668460e417931966ffecb
parent02f0ad8e8de8cf5344f8f0fa26d9529b8339da47
hwmon: (w83l786ng) Convert macros to functions to avoid TOCTOU

The macros FAN_FROM_REG and TEMP_FROM_REG evaluate their 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 macros to static functions. 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/
Fixes: 85f03bccd6e0 ("hwmon: Add support for Winbond W83L786NG/NR")
Cc: stable@vger.kernel.org
Signed-off-by: Gui-Dong Han <hanguidong02@gmail.com>
Link: https://lore.kernel.org/r/20251128123816.3670-1-hanguidong02@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/w83l786ng.c