Re: [PATCH 1/3] hwmon: (ltc4282) Avoid overflow in maximum power calculation
[email protected] Wed, 05 Aug 2026 01:07:26 +0000
| Newsgroups | org.kernel.vger.linux-hwmon |
|---|---|
| Message-ID | <[email protected]> |
> During device initialization in ltc4282_set_max_limits(), the calculation
> of the maximum power limit can suffer from a 32-bit integer overflow.
>=20
> static int ltc4282_set_max_limits(struct ltc4282_state *st)
> {
> ...
> st->power_max =3D DIV_ROUND_CLOSEST(st->vsense_max * DECA * MILLI,
> st->rsense) * st->vfs_out;
> ...
> }
>=20
> The result of DIV_ROUND_CLOSEST() evaluates to a 32-bit unsigned integer
> on 32-bit architectures. This result is then multiplied by st->vfs_out,
> which is a 16-bit unsigned integer. According to C promotion rules, since
> both operands are 32-bit or smaller, the multiplication is performed in
> [ ... ]
>=20
> Reported-by: Sashiko <[email protected]>
> Fixes: cbc29538dbf7d ("hwmon: Add driver for LTC4282")
> Cc: Nuno Sa <[email protected]>
> Signed-off-by: Guenter Roeck <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
--=20
Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20260805005721.1566=
[email protected]?part=3D1