From: sashiko-bot@kernel.org
To: "Herman van Hazendonk" <github.com@herrie.org>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH 1/1] iio: light: isl29018: support cover-glass gain compensation via DT
Date: Thu, 04 Jun 2026 05:57:20 +0000 [thread overview]
Message-ID: <20260604055721.58A621F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260604054723.2983181-2-github.com@herrie.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Multiple 32-bit integer overflows in `isl29018_read_lux()` lead to incorrect, wrapped, or negative sensor readings.
--
commit 190a907a89f0aeaf207c50457cf9f79e29e324c2
Author: Herman van Hazendonk <github.com@herrie.org>
iio: light: isl29018: support cover-glass gain compensation via DT
This commit introduces a new device-tree property, "isil,cover-comp-gain",
to seed the in_illuminance0_calibscale value at probe time. This allows
hardware platforms to compensate for optical loss from tinted or coated
cover glass over the sensor. The default value is set to 1 to maintain
compatibility with existing systems.
[ ... ]
> diff --git a/drivers/iio/light/isl29018.c b/drivers/iio/light/isl29018.c
> --- a/drivers/iio/light/isl29018.c
> +++ b/drivers/iio/light/isl29018.c
> @@ -727,7 +727,16 @@ static int isl29018_probe(struct i2c_client *client)
> mutex_init(&chip->lock);
>
> chip->type = dev_id;
> + /*
> + * Allow boards that mount the sensor behind tinted / coated cover
> + * glass to bake the optical-loss compensation into firmware via
> + * "isil,cover-comp-gain", following the precedent set by
> + * tsl2563.c. The value seeds calibscale (default 1), so userspace
> + * can still retune through in_illuminance0_calibscale.
> + */
> chip->calibscale = 1;
> + device_property_read_u32(&client->dev, "isil,cover-comp-gain",
> + &chip->calibscale);
[Severity: High]
This is a pre-existing issue, but does setting a large calibscale here
exacerbate an integer overflow in isl29018_read_lux()?
In isl29018_read_lux(), the calculations for data_x_range and the final *lux
value rely on 32-bit unsigned arithmetic:
drivers/iio/light/isl29018.c:isl29018_read_lux() {
...
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;
...
}
The multiplication lux_data * chip->scale.uscale can reach ~64 billion
(e.g., 65535 * 976,562), overflowing UINT_MAX (4,294,967,295) and losing
precision.
Furthermore, the subsequent multiplication data_x_range * chip->calibscale
easily exceeds 2 billion if calibscale is seeded to a high value (like 100,
as the commit message suggests). Because the result is stored in the signed
int *lux, exceeding 2 billion causes the value to wrap, resulting in massive
negative lux values being reported to userspace.
Could these 32-bit multiplications be updated to use 64-bit math or scaled
down to prevent overflow in bright light environments?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260604054723.2983181-2-github.com@herrie.org?part=1
next prev parent reply other threads:[~2026-06-04 5:57 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 [this message]
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
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=20260604055721.58A621F00893@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