From: sashiko-bot@kernel.org
To: "Herman van Hazendonk" <github.com@herrie.org>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v2 1/2] iio: light: isl29018: fix 32-bit overflow in isl29018_read_lux()
Date: Thu, 04 Jun 2026 06:58:42 +0000 [thread overview]
Message-ID: <20260604065842.BC6821F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260604064925.3097108-2-github.com@herrie.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The patch introduces 64-bit divisions using the standard `/` operator, which will cause a linker error (`undefined reference to __udivdi3`) on 32-bit architectures.
--
commit 37588d2a24184ed61a15690c807e6b4b16aa4002
Author: Herman van Hazendonk <github.com@herrie.org>
iio: light: isl29018: fix 32-bit overflow in isl29018_read_lux()
This commit addresses an overflow in isl29018_read_lux() by changing
intermediate calculation variables to u64. It then clamps the final result
to INT_MAX before storing it in the signed output variable.
> diff --git a/drivers/iio/light/isl29018.c b/drivers/iio/light/isl29018.c
> index 1b4c184230489..927018c531e8d 100644
> --- a/drivers/iio/light/isl29018.c
> +++ b/drivers/iio/light/isl29018.c
> @@ -193,17 +193,18 @@ static int isl29018_read_sensor_input(struct isl29018_chip *chip, int mode)
> static int isl29018_read_lux(struct isl29018_chip *chip, int *lux)
> {
> int lux_data;
> - unsigned int data_x_range;
> + u64 data_x_range, result;
[ ... ]
> - data_x_range = lux_data * chip->scale.scale +
> - lux_data * chip->scale.uscale / 1000000;
> - *lux = data_x_range * chip->calibscale +
> - data_x_range * chip->ucalibscale / 1000000;
> + data_x_range = (u64)lux_data * chip->scale.scale +
> + (u64)lux_data * chip->scale.uscale / 1000000;
> + result = data_x_range * chip->calibscale +
> + data_x_range * chip->ucalibscale / 1000000;
[Severity: Low]
Will this cause a linker error on 32-bit architectures?
Since data_x_range and the result of the multiplications are now u64, using
the native division operator (/) for 1000000 will result in an undefined
reference to __udivdi3 when compiling for 32-bit platforms.
Should this use div_u64() from <linux/math64.h> instead?
> + *lux = (int)min_t(u64, result, INT_MAX);
>
> return 0;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260604064925.3097108-1-github.com@herrie.org?part=1
next prev parent reply other threads:[~2026-06-04 6:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-04 5:47 [PATCH 0/1] iio: light: isl29018: cover-glass gain compensation via DT Herman van Hazendonk
2026-06-04 5:47 ` [PATCH 1/1] iio: light: isl29018: support " Herman van Hazendonk
2026-06-04 5:57 ` sashiko-bot
2026-06-04 7:17 ` Andy Shevchenko
2026-06-04 7:22 ` Joshua Crofts
2026-06-04 6:49 ` [PATCH v2 0/2] iio: light: isl29018: overflow fix + cover-glass gain " Herman van Hazendonk
2026-06-04 6:49 ` [PATCH v2 1/2] iio: light: isl29018: fix 32-bit overflow in isl29018_read_lux() Herman van Hazendonk
2026-06-04 6:58 ` sashiko-bot [this message]
2026-06-04 6:49 ` [PATCH v2 2/2] iio: light: isl29018: support cover-glass gain compensation via DT Herman van Hazendonk
2026-06-04 7:00 ` sashiko-bot
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=20260604065842.BC6821F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=github.com@herrie.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox