From: Jonathan Cameron <jic23@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Josef Bacik" <josef@toxicpanda.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
stable <stable@kernel.org>,
"Subhajit Ghosh" <subhajit.ghosh@tweaklogic.com>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>
Subject: Re: [PATCH 08/15] iio: light: apds9306: push events to the IIO device
Date: Sun, 1 Nov 2026 02:20:27 +0000 [thread overview]
Message-ID: <20261101022027.61c4fe45@jic23-hlaptop> (raw)
In-Reply-To: <20261027-llm-char-misc-iio-v1-8-0d818334f6c7@linuxfoundation.org>
On Tue, 27 Oct 2026 17:19:12 +0100
Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:
> From: Josef Bacik <josef@toxicpanda.com>
>
> Reading a light channel while threshold events are enabled can push an
> event through a pointer that is not an IIO device, corrupting memory or
> crashing the kernel.
>
> apds9306_read_data() derives indio_dev with dev_to_iio_dev(data->dev),
> but data->dev is the I2C client's device, not the device embedded in
> struct iio_dev. When the status register read by the poll loop has
> APDS9306_ALS_INT_STAT_MASK set, the bogus pointer is passed to
> iio_push_event() and iio_get_time_ns(), which dereference the event
> interface and clock id of a structure that does not exist.
>
> The bug was found by code inspection and has not been reproduced.
>
> Fix by taking the IIO device from the I2C client's driver data, which
> probe sets with i2c_set_clientdata().
I'd rather we just passed in the iio_dev given the caller always has
it anyway. Pass that instead of struct apds9306_data *data and
use iio_priv() in here to get that locally.
>
> Fixes: 620d1e6c7a3f ("iio: light: Add support for APDS9306 Light Sensor")
> Cc: stable <stable@kernel.org>
> Cc: Subhajit Ghosh <subhajit.ghosh@tweaklogic.com>
> Cc: David Lechner <dlechner@baylibre.com>
> Cc: "Nuno Sá" <nuno.sa@analog.com>
> Cc: Andy Shevchenko <andy@kernel.org>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> drivers/iio/light/apds9306.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/light/apds9306.c b/drivers/iio/light/apds9306.c
> index 7dd41136734f..79138422221d 100644
> --- a/drivers/iio/light/apds9306.c
> +++ b/drivers/iio/light/apds9306.c
> @@ -462,7 +462,7 @@ static int apds9306_power_state(struct apds9306_data *data, bool state)
> static int apds9306_read_data(struct apds9306_data *data, int *val, int reg)
> {
> struct device *dev = data->dev;
> - struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> + struct iio_dev *indio_dev = dev_get_drvdata(dev);
> struct apds9306_regfields *rf = &data->rf;
> u64 ev_code;
> int ret, delay, intg_time, intg_time_idx, repeat_rate_idx, int_src;
>
next prev parent reply other threads:[~2026-11-01 2:20 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 16:19 [PATCH 00/15] IIO: a bunch of llm-found fixes Greg Kroah-Hartman
2026-10-27 16:19 ` [PATCH 01/15] iio: buffer: let the block keep its DMA fence Greg Kroah-Hartman
2026-10-28 9:30 ` Nuno Sá
2026-10-29 14:40 ` Nuno Sá
2026-10-29 15:43 ` Benoît Monin
2026-10-27 16:19 ` [PATCH 02/15] iio: trigger: fail the attach if no sub-IRQ is left Greg Kroah-Hartman
2026-10-28 9:38 ` Nuno Sá
2026-11-01 2:53 ` Jonathan Cameron
2026-10-27 16:19 ` [PATCH 03/15] iio: accel: adxl367: don't stay in standby on -EINVAL Greg Kroah-Hartman
2026-10-28 10:01 ` Nuno Sá
2026-10-27 16:19 ` [PATCH 04/15] iio: accel: adxl380: " Greg Kroah-Hartman
2026-10-28 10:02 ` Nuno Sá
2026-11-01 2:26 ` Jonathan Cameron
2026-10-27 16:19 ` [PATCH 05/15] iio: adc: check the result of ad_sd_init() Greg Kroah-Hartman
2026-10-28 9:40 ` Nuno Sá
2026-11-01 2:23 ` Jonathan Cameron
2026-10-27 16:19 ` [PATCH 06/15] iio: adc: ad7923: add the AD7927 to the SPI ID table Greg Kroah-Hartman
2026-10-28 9:35 ` Nuno Sá
2026-11-01 2:22 ` Jonathan Cameron
2026-10-27 16:19 ` [PATCH 07/15] iio: addac: ad74413r: fix the values of set_multiple Greg Kroah-Hartman
2026-10-28 9:38 ` Nuno Sá
2026-11-01 2:21 ` Jonathan Cameron
2026-10-27 16:19 ` [PATCH 08/15] iio: light: apds9306: push events to the IIO device Greg Kroah-Hartman
2026-11-01 2:20 ` Jonathan Cameron [this message]
2026-10-27 16:19 ` [PATCH 09/15] iio: light: tsl2591: don't divide by zero in the dark Greg Kroah-Hartman
2026-10-30 8:24 ` Joshua Crofts
2026-10-27 16:19 ` [PATCH 10/15] iio: light: tsl2591: don't divide by zero with low gain Greg Kroah-Hartman
2026-10-28 2:13 ` Jonathan Cameron
2026-10-28 4:16 ` Greg Kroah-Hartman
2026-10-27 16:19 ` [PATCH 11/15] iio: hid-sensors: fix a division by zero Greg Kroah-Hartman
2026-11-01 2:17 ` Jonathan Cameron
2026-10-27 16:19 ` [PATCH 12/15] iio: imu: inv_mpu6050: don't disable the IRQ under lock Greg Kroah-Hartman
2026-11-01 2:14 ` Jonathan Cameron
2026-10-27 16:19 ` [PATCH 13/15] iio: proximity: sx9500: hand on probe deferral of GPIOs Greg Kroah-Hartman
2026-10-28 2:09 ` Jonathan Cameron
2026-10-27 16:19 ` [PATCH 14/15] iio: scmi: use 64-bit divisions for rates and intervals Greg Kroah-Hartman
2026-10-28 1:46 ` Jonathan Cameron
2026-10-27 16:19 ` [PATCH 15/15] iio: sx9310: use the data of the I2C table Greg Kroah-Hartman
2026-10-27 16:25 ` Biju Das
2026-10-27 16:38 ` Andy Shevchenko
2026-11-01 2:11 ` Jonathan Cameron
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=20261101022027.61c4fe45@jic23-hlaptop \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=gregkh@linuxfoundation.org \
--cc=josef@toxicpanda.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=stable@kernel.org \
--cc=subhajit.ghosh@tweaklogic.com \
/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
all inboxes | Powered by JetHome®