Files
linux-net/drivers/hwmon
Gui-Dong Han b8d5acdcf5 hwmon: (max16065) Use local variable to avoid TOCTOU
In max16065_current_show, data->curr_sense is read twice: once for the
error check and again for the calculation. Since
i2c_smbus_read_byte_data returns negative error codes on failure, if the
data changes to an error code between the check and the use, ADC_TO_CURR
results in an incorrect calculation.

Read data->curr_sense into a local variable to ensure consistency. Note
that data->curr_gain is constant and safe to access directly.

This aligns max16065_current_show with max16065_input_show, which
already uses a local variable for the same reason.

Link: https://lore.kernel.org/all/CALbr=LYJ_ehtp53HXEVkSpYoub+XYSTU8Rg=o1xxMJ8=5z8B-g@mail.gmail.com/
Fixes: f5bae2642e ("hwmon: Driver for MAX16065 System Manager and compatibles")
Cc: stable@vger.kernel.org
Signed-off-by: Gui-Dong Han <hanguidong02@gmail.com>
Link: https://lore.kernel.org/r/20251128124709.3876-1-hanguidong02@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2025-11-28 08:36:25 -08:00
..
2025-06-16 06:30:57 -07:00
2025-11-02 11:07:16 -08:00
2025-03-18 08:03:40 -07:00
2025-10-15 11:02:43 -07:00
2025-05-12 18:05:54 -07:00
2025-09-07 16:33:47 -07:00
2025-11-26 09:03:56 -08:00
2025-10-15 11:02:43 -07:00
2025-10-17 05:59:12 -07:00
2025-09-25 08:08:13 -07:00
2025-09-09 05:26:11 -07:00
2025-10-15 11:02:43 -07:00