]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 Jan 2026 11:57:30 +0000 (12:57 +0100)
commit4fc2f8fbfdd43257c9a90b6730e80c0dc952575c
treeddd414c9e3ac481b8ad2f6bc57b3834c417ba5c8
parentc8cf0c2bdcccc6634b6915ff793b844e12436680
hwmon: (w83l786ng) Convert macros to functions to avoid TOCTOU

commit 07272e883fc61574b8367d44de48917f622cdd83 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hwmon/w83l786ng.c