]> 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>
Thu, 8 Jan 2026 09:14:30 +0000 (10:14 +0100)
commit96221a072d5d06e07bc1a10cb799258c5e8bde22
tree5dbe572655a8706d9b601125d67ca29f6e960449
parenta9fb6e8835a22f5796c1182ed612daed3fd273af
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