Re: [PATCH 15/15] iio: sx9310: use the data of the I2C table

From: Jonathan Cameron

Date: Sat Oct 31 2026 - 22:11:32 EST


On Tue, 27 Oct 2026 17:19:19 +0100
Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:

> From: Josef Bacik <josef@xxxxxxxxxxxxxx>
>
> sx9310_check_whoami() takes the chip information from
> device_get_match_data(), which only looks at the OF and ACPI tables, and
> dereferences it. For a client which was bound through the i2c_device_id
> table, for instance one created with
>
> echo sx9310 0x28 > /sys/bus/i2c/devices/i2c-1/new_device
>
> it returns NULL, and the kernel oopses as soon as something at that address
> answers the read of the WHOAMI register.
>
> The I2C table has the same pointers. Use i2c_get_match_data(), which falls
> back to it.
>
> Fixes: 21fd3b1373f6 ("iio: proximity: sx9310: Convert enum->pointer for match data table")
> Cc: stable <stable@xxxxxxxxxx>
> Cc: Jonathan Cameron <jic23@xxxxxxxxxx>
> Cc: David Lechner <dlechner@xxxxxxxxxxxx>
> Cc: "Nuno Sá" <nuno.sa@xxxxxxxxxx>
> Cc: Andy Shevchenko <andy@xxxxxxxxxx>
> Cc: "Uwe Kleine-König (The Capable Hub)" <u.kleine-koenig@xxxxxxxxxxxx>
> Cc: Siratul Islam <email@xxxxxxxx>
> Cc: Matti Vaittinen <mazziesaccount@xxxxxxxxx>
> Cc: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>
> Cc: Stephen Boyd <swboyd@xxxxxxxxxxxx>
Applied to the fixes-togreg branch (I'll rebase and send a pull
for that after rc1), though I pruned most of these out to reduce noise
in the git log

Thanks,

Jonathan

> Signed-off-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> ---
> drivers/iio/proximity/sx9310.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c
> index 79ba46d8a0aa..2585b9c6fb69 100644
> --- a/drivers/iio/proximity/sx9310.c
> +++ b/drivers/iio/proximity/sx9310.c
> @@ -891,7 +891,7 @@ static int sx9310_check_whoami(struct device *dev,
> if (ret)
> return ret;
>
> - ddata = device_get_match_data(dev);
> + ddata = i2c_get_match_data(data->client);
> if (ddata->whoami != whoami)
> return -ENODEV;
>
>