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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.