Re: [PATCH] iio: proximity: sx9310: fix NULL pointer dereference in sx9310_check_whoami
Andy Shevchenko <[email protected]>
| Newsgroups | org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel |
|---|---|
| Organization | Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo |
| Message-ID | <[email protected]> |
On Tue, Aug 25, 2026 at 05:18:01PM +0800, Yang Zi 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. -ENODATA, please. ... > Â Â Â ddata = device_get_match_data(dev); > +Â Â if (!ddata) > +Â Â Â Â return -ENODEV; + blank line. > Â Â Â if (ddata->whoami != whoami) > Â Â Â Â Â return -ENODEV; > Â -- With Best Regards, Andy Shevchenko