From: sashiko-bot@kernel.org
To: "Pradhan, Sanman" <sanman.pradhan@hpe.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v3 2/3] hwmon: (isl28022) Fix integer overflow in power calculation on 32-bit
Date: Wed, 08 Apr 2026 17:28:51 +0000 [thread overview]
Message-ID: <20260408172852.4C680C19421@smtp.kernel.org> (raw)
In-Reply-To: <20260408163029.353777-3-sanman.pradhan@hpe.com>
Sashiko AI review found 1 potential issue(s):
- [Low] The use of the `min()` macro with mixed types (`u64` and `long`) will cause build failures when this patch is backported to older stable kernels.
--
commit 7d032fe46f91e450d244ac30f5851808fee10667
Author: Sanman Pradhan <psanman@juniper.net>
hwmon: (isl28022) Fix integer overflow in power calculation on 32-bit
This commit fixes an integer overflow on 32-bit systems in the power
calculation of the isl28022 driver by switching to 64-bit arithmetic
and using div_u64().
> diff --git a/drivers/hwmon/isl28022.c b/drivers/hwmon/isl28022.c
> index c2e559dde63f6..c5a34ceedcdb2 100644
> --- a/drivers/hwmon/isl28022.c
> +++ b/drivers/hwmon/isl28022.c
[ ... ]
> @@ -185,8 +186,8 @@ static int isl28022_read_power(struct device *dev, u32 attr, long *val)
> ISL28022_REG_POWER, ®val);
> if (err < 0)
> return err;
> - *val = ((51200000L * ((long)data->gain)) /
> - (long)data->shunt) * (long)regval;
> + *val = min(div_u64(51200000ULL * data->gain * regval,
> + data->shunt), LONG_MAX);
Is there a risk of build failures when this patch is backported to older
stable kernels?
Since this patch is marked with "Cc: stable@vger.kernel.org", it will likely
be backported to older LTS kernels like 5.15 or 6.1. While modern kernels
have relaxed the type-checking in the min() macro to allow safely comparable
mixed types, older kernels strictly enforce identical types via pointer
comparison.
Comparing a u64 (from div_u64()) and a long (LONG_MAX) might trigger a
"comparison of distinct pointer types lacks a cast" compiler error during
backporting.
Would it be better to use min_t(u64, div_u64(...), LONG_MAX) to avoid this
issue on older trees?
> break;
> default:
> return -EOPNOTSUPP;
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260408163029.353777-1-sanman.pradhan@hpe.com?part=2
next prev parent reply other threads:[~2026-04-08 17:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-08 16:30 [PATCH v3 0/3] hwmon: Fix bugs in pt5161l, isl28022, and powerz Pradhan, Sanman
2026-04-08 16:31 ` [PATCH v3 1/3] hwmon: (pt5161l) Fix bugs in pt5161l_read_block_data() Pradhan, Sanman
2026-04-08 17:08 ` sashiko-bot
2026-04-08 17:22 ` Pradhan, Sanman
2026-04-08 18:28 ` Guenter Roeck
2026-04-08 16:31 ` [PATCH v3 2/3] hwmon: (isl28022) Fix integer overflow in power calculation on 32-bit Pradhan, Sanman
2026-04-08 17:28 ` sashiko-bot [this message]
2026-04-08 16:31 ` [PATCH v3 3/3] hwmon: (powerz) Fix use-after-free and signal handling on USB disconnect Pradhan, Sanman
2026-04-08 17:58 ` sashiko-bot
2026-04-08 19:30 ` Thomas Weißschuh
2026-04-09 15:50 ` Pradhan, Sanman
2026-04-09 16:21 ` Thomas Weißschuh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260408172852.4C680C19421@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=sanman.pradhan@hpe.com \
--cc=sashiko@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.