Re: [PATCH v6] hwmon: (ina2xx) Fix various overflow issues

[email protected]
Newsgroups org.kernel.vger.linux-hwmon
Message-ID <[email protected]>
> Sashiko reports several integer overflow problems in the ina2xx driver
> caused by unbounded multiplications and inadequate types for intermediate
> calculations.
> 
> Specifically:
> - In ina2xx_get_value(), the return type is changed from int to long.
>   Intermediate calculations for current are now performed using 64-bit
>   types to prevent 32-bit integer overflow before the division by 1000.
> - When calculating power in ina2xx_get_value() and
>   sy24655_average_power_read(), interim values are cast to u64 and clamped
>   to LONG_MAX. This prevents overflow when regval or accumulator_24 is
>   multiplied by power_lsb_uW.
> - In ina226_alert_to_reg(), the clamping logic is rewritten using min_t().
>   This safely avoids integer overflows when scaling user-provided values
>   for shunt voltage, bus voltage, power, and current limits.
> 
> Cc: Loic Poulain <[email protected]>
> Fixes: ab7fbee452be ("hwmon: (ina2xx) Fix various overflow issues")
> Signed-off-by: Guenter Roeck <[email protected]>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.