From: Mark Brown <broonie@kernel.org>
To: wangdich9700@163.com
Cc: tiwai@suse.com, linux-sound@vger.kernel.org,
linux-kernel@vger.kernel.org,
wangdicheng <wangdicheng@kylinos.cn>
Subject: Re: [PATCH] ASoC: aw88395: Fix kernel panic caused by invalid GPIO error pointer
Date: Tue, 28 Apr 2026 08:24:23 +0900 [thread overview]
Message-ID: <ae_wJ2JZFaKQvnJv@sirena.co.uk> (raw)
In-Reply-To: <20260427022946.48886-1-wangdich9700@163.com>
[-- Attachment #1: Type: text/plain, Size: 980 bytes --]
On Mon, Apr 27, 2026 at 10:29:46AM +0800, wangdich9700@163.com wrote:
> From: wangdicheng <wangdicheng@kylinos.cn>
>
> In aw88395_i2c_probe(), if `devm_gpiod_get_optional()` fails, it returns
> an ERR_PTR() error pointer. The current code only prints a message and
> continues execution, leaving `aw88395->reset_gpio` as an invalid pointer.
>
> Later, in `aw88395_hw_reset()`, this invalid pointer is passed to
> `gpiod_set_value_cansleep()`, which dereferences it and causes a kernel
> panic.
>
> For optional GPIOs, `devm_gpiod_get_optional()` returns NULL if the GPIO
> is not defined in the DT, which is safe. If it returns an ERR_PTR, it
> means a real error occurred (e.g., -EPROBE_DEFER) and the probe must be
> aborted. Fix this by returning the error code when IS_ERR() is true.
This looks OK in so far as it goes but there's other bugs in the driver,
at least printing a dev_err() if the GPIO is missing which doesn't
exactly sound optonal to me.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
prev parent reply other threads:[~2026-04-27 23:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-27 2:29 [PATCH] ASoC: aw88395: Fix kernel panic caused by invalid GPIO error pointer wangdich9700
2026-04-27 23:24 ` Mark Brown [this message]
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=ae_wJ2JZFaKQvnJv@sirena.co.uk \
--to=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=tiwai@suse.com \
--cc=wangdich9700@163.com \
--cc=wangdicheng@kylinos.cn \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox