From: sashiko-bot@kernel.org
To: "Svyatoslav Ryhel" <clamor95@gmail.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v3 1/4] iio: light: ltr501: Switch to read_avail() op from manual attribute registration
Date: Sun, 08 Nov 2026 09:50:27 +0000 [thread overview]
Message-ID: <sashiko-outbox-203672@kernel.org> (raw)
In-Reply-To: <20261108094253.83899-2-clamor95@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] iio: light: ltr501: stack use-after-return in
ltr501_read_avail()
--
commit 865563656e5e5188134453546f2c2ea7f31369cb
Author: Svyatoslav Ryhel <clamor95@gmail.com>
iio: light: ltr501: Switch to read_avail() op from manual attribute registration
This commit replaces manual *_available sysfs attribute registration in
the ltr501 driver with the IIO read_avail() callback and channel
info_mask_*_available masks.
> diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c
> index 302be2fc314c5..1ddd0dfd55ea2 100644
> --- a/drivers/iio/light/ltr501.c
> +++ b/drivers/iio/light/ltr501.c
[ ... ]
> @@ -1111,111 +1124,67 @@ static int ltr501_write_event_config(struct iio_dev *indio_dev,
> return -EINVAL;
> }
>
> -static ssize_t ltr501_show_proximity_scale_avail(struct device *dev,
> - struct device_attribute *attr,
> - char *buf)
> +static int ltr501_read_avail(struct iio_dev *indio_dev,
> + struct iio_chan_spec const *chan,
> + const int **vals, int *type, int *length, long mask)
> {
> - struct ltr501_data *data = iio_priv(dev_to_iio_dev(dev));
> + struct ltr501_data *data = iio_priv(indio_dev);
> const struct ltr501_chip_info *info = data->chip_info;
> - ssize_t len = 0;
> - int i;
> -
> - for (i = 0; i < info->ps_gain_tbl_size; i++) {
> - if (info->ps_gain[i].scale == LTR501_RESERVED_GAIN)
> - continue;
> - len += scnprintf(buf + len, PAGE_SIZE - len, "%d.%06d ",
> - info->ps_gain[i].scale,
> - info->ps_gain[i].uscale);
> - }
>
> - buf[len - 1] = '\n';
> + switch (mask) {
> + case IIO_CHAN_INFO_SCALE:
> + if (chan->type == IIO_INTENSITY) {
> + int valid_als_gains[ARRAY_SIZE(ltr559_als_gain_tbl) * 2];
> + int j = 0;
> +
> + for (int i = 0; i < info->als_gain_tbl_size; i++) {
> + if (info->als_gain[i].scale == LTR501_RESERVED_GAIN)
> + continue;
> +
> + valid_als_gains[j++] = info->als_gain[i].scale;
> + valid_als_gains[j++] = info->als_gain[i].uscale;
> + }
> +
> + *length = j;
> + *vals = (const int *)valid_als_gains;
[Severity: High]
Does assigning valid_als_gains to *vals return a dangling stack pointer?
valid_als_gains has automatic storage duration inside the if block, so
when iio_read_channel_info_avail() calls iio_format_avail_list() after
ltr501_read_avail() returns, reading in_intensity_scale_available
triggers a stack use-after-return and exposes kernel stack contents to
userspace.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261108094253.83899-1-clamor95@gmail.com?part=1
next prev parent reply other threads:[~2026-11-08 9:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-08 9:42 [PATCH v3 0/4] iio: light: ltr501: Add LTR-659PS-01 prox sensor support Svyatoslav Ryhel
2026-11-08 9:42 ` [PATCH v3 1/4] iio: light: ltr501: Switch to read_avail() op from manual attribute registration Svyatoslav Ryhel
2026-11-08 9:50 ` sashiko-bot [this message]
2026-11-09 20:03 ` Andy Shevchenko
2026-11-08 9:42 ` [PATCH v3 2/4] iio: light: ltr501: Switch to modern match mechanism Svyatoslav Ryhel
2026-11-08 9:42 ` [PATCH v3 3/4] dt-bindings: iio: light: ltr501: Document LTR659 proximity sensor Svyatoslav Ryhel
2026-11-08 9:42 ` [PATCH v3 4/4] iio: light: ltr501: Add support for the LTR-659PS-01 " Svyatoslav Ryhel
2026-11-08 10:01 ` sashiko-bot
2026-11-08 21:48 ` kernel test robot
2026-11-09 20:04 ` Andy Shevchenko
2026-11-09 20:07 ` Svyatoslav Ryhel
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=sashiko-outbox-203672@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=clamor95@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).