Re: [PATCH 2/2] hwmon: (ltc2992) Fix u32 overflow in power read path

From: Guenter Roeck

Date: Thu Apr 30 2026 - 13:24:23 EST


On Thu, Apr 16, 2026 at 09:59:40PM +0000, Pradhan, Sanman wrote:
> From: Sanman Pradhan <psanman@xxxxxxxxxxx>
>
> ltc2992_get_power() computes the divisor for mul_u64_u32_div() as
> r_sense_uohm * 1000. This multiplication overflows u32 when
> r_sense_uohm exceeds about 4.29 ohms (4294967 micro-ohms), producing
> a truncated divisor and an incorrect power reading.
>
> Cancel the factor of 1000 from both the numerator
> (VADC_UV_LSB * IADC_NANOV_LSB = 312500000) and the divisor
> (r_sense_uohm * 1000), giving (VADC_UV_LSB / 1000) * IADC_NANOV_LSB
> = 312500 as the numerator and plain r_sense_uohm as the divisor.
> The cancellation is exact because LTC2992_VADC_UV_LSB (25000) is
> divisible by 1000.
>
> This is the read-path counterpart of the write-path fix applied in
> the preceding patch.
>
> Fixes: b0bd407e94b03 ("hwmon: (ltc2992) Add support")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Sanman Pradhan <psanman@xxxxxxxxxxx>

Applied.

Thanks,
Guenter