Re: [PATCH] power: supply: hwmon: reject writes that do not fit in an int

From: Sebastian Reichel

Date: Sat Dec 05 2026 - 17:22:19 EST



On Sat, 28 Nov 2026 21:17:49 -0600, Weidong Wang wrote:
> hwmon_attr_store() parses the user buffer with kstrtol() and passes the
> resulting long to power_supply_hwmon_write(), which stores it in the int
> member of union power_supply_propval before converting the unit:
>
> pspval.intval = val;
>
> On 64-bit kernels a value outside the int range is silently truncated by
> this assignment. For current and voltage attributes the following
> check_mul_overflow() only sees the truncated value, and for temperature
> attributes there is no check at all. Writing 4294967297 to in0_max, for
> example, is accepted and sets VOLTAGE_MAX to 1000 uV instead of failing.
>
> [...]

Applied, thanks!

[1/1] power: supply: hwmon: reject writes that do not fit in an int
commit: 96e000d752ce8deb85e99a93d56bc6307cde66c6

Best regards,
--
Sebastian Reichel <sebastian.reichel@xxxxxxxxxxxxx>