From: wangdich9700@163.com
To: broonie@kernel.org, tiwai@suse.com, wangdich9700@163.com
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
wangdicheng <wangdicheng@kylinos.cn>
Subject: [PATCH] ASoC: aw88395: Fix kernel panic caused by invalid GPIO error pointer
Date: Mon, 27 Apr 2026 10:29:46 +0800 [thread overview]
Message-ID: <20260427022946.48886-1-wangdich9700@163.com> (raw)
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.
Signed-off-by: wangdicheng <wangdicheng@kylinos.cn>
---
sound/soc/codecs/aw88395/aw88395.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/codecs/aw88395/aw88395.c b/sound/soc/codecs/aw88395/aw88395.c
index 3602b5b9f7d7..e60cd7e239cc 100644
--- a/sound/soc/codecs/aw88395/aw88395.c
+++ b/sound/soc/codecs/aw88395/aw88395.c
@@ -523,7 +523,7 @@ static int aw88395_i2c_probe(struct i2c_client *i2c)
aw88395->reset_gpio = devm_gpiod_get_optional(&i2c->dev, "reset", GPIOD_OUT_LOW);
if (IS_ERR(aw88395->reset_gpio))
- dev_info(&i2c->dev, "reset gpio not defined\n");
+ return PTR_ERR(aw88395->reset_gpio);
/* hardware reset */
aw88395_hw_reset(aw88395);
--
2.25.1
next reply other threads:[~2026-04-27 2:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-27 2:29 wangdich9700 [this message]
2026-04-27 23:24 ` [PATCH] ASoC: aw88395: Fix kernel panic caused by invalid GPIO error pointer Mark Brown
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=20260427022946.48886-1-wangdich9700@163.com \
--to=wangdich9700@163.com \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=tiwai@suse.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