All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joshua Crofts <joshua.crofts1@gmail.com>
To: Yang Zi <2959243019@qq.com>
Cc: jic23@kernel.org, linux-iio@vger.kernel.org,
	dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
	u.kleine-koenig@baylibre.com, dakr@kernel.org,
	o-takashi@sakamocchi.jp, email@sirat.me,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: proximity: sx9310: fix NULL pointer dereference in sx9310_check_whoami
Date: Tue, 25 Aug 2026 11:28:36 +0200	[thread overview]
Message-ID: <20260825112836.00002aef@gmail.com> (raw)
In-Reply-To: <tencent_1936AF0C31F45000EFB7B38019EFD4A06C07@qq.com>

On Tue, 25 Aug 2026 17:18:01 +0800
Yang Zi <2959243019@qq.com> 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 <2959243019@qq.com>
> ---
> 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

  reply	other threads:[~2026-08-25  9:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25  9:18 [PATCH] iio: proximity: sx9310: fix NULL pointer dereference in sx9310_check_whoami Yang Zi
2026-08-25  9:28 ` Joshua Crofts [this message]
2026-08-26 14:00 ` Andy Shevchenko
2026-08-31  0:19 ` 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=20260825112836.00002aef@gmail.com \
    --to=joshua.crofts1@gmail.com \
    --cc=2959243019@qq.com \
    --cc=andy@kernel.org \
    --cc=dakr@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=email@sirat.me \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=o-takashi@sakamocchi.jp \
    --cc=u.kleine-koenig@baylibre.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.