Re: [PATCH] iio: proximity: sx9310: fix NULL pointer dereference in sx9310_check_whoami
Joshua Crofts <[email protected]>
| Newsgroups | org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
On Tue, 25 Aug 2026 17:18:01 +0800 Yang Zi <[email protected]> wrote: > device_get_match_data() can return NULL, e.g. when the device is matched > through the I2C device ID table rather than the OF/ACPI match tables. In > that case sx9310_check_whoami() dereferences a NULL pointer when reading > ddata->whoami. > > Return -ENODEV if no match data is found to avoid the NULL pointer > dereference. > > Signed-off-by: Yang Zi <[email protected]> > --- > diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c > index 79ba46d8a0aa..305b41f2847d 100644 > --- a/drivers/iio/proximity/sx9310.c > +++ b/drivers/iio/proximity/sx9310.c > @@ -892,6 +892,8 @@ static int sx9310_check_whoami(struct device *dev, > return ret; > > ddata = device_get_match_data(dev); > + if (!ddata) > + return -ENODEV; -ENODATA is preferred in IIO. Also looking at the cc list, no need to add addresses that have "commit_signer" next to them when running get_maintainer.pl, just maintainers, reviewers and mailing lists. -- Kind regards, Joshua Crofts