[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260130091904.3426149-1-nichen@iscas.ac.cn>
Date: Fri, 30 Jan 2026 17:19:04 +0800
From: Chen Ni <nichen@...as.ac.cn>
To: lgirdwood@...il.com,
broonie@...nel.org,
perex@...ex.cz,
tiwai@...e.com,
ckeepax@...nsource.cirrus.com,
kuninori.morimoto.gx@...esas.com,
srinivas.kandagatla@....qualcomm.com,
krzk@...nel.org
Cc: linux-sound@...r.kernel.org,
linux-kernel@...r.kernel.org,
Chen Ni <nichen@...as.ac.cn>
Subject: [PATCH] ASoC: codecs: max98390: Check return value of devm_gpiod_get_optional() in max98390_i2c_probe()
The devm_gpiod_get_optional() function may return an error pointer
(ERR_PTR) in case of a genuine failure during GPIO acquisition,
not just NULL which indicates the legitimate absence of an optional
GPIO.
Add an IS_ERR() check after the function call to catch such errors and
propagate them to the probe function, ensuring the driver fails to load
safely rather than proceeding with an invalid pointer.
Signed-off-by: Chen Ni <nichen@...as.ac.cn>
---
sound/soc/codecs/max98390.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sound/soc/codecs/max98390.c b/sound/soc/codecs/max98390.c
index 3dd4dd94bc37..ff58805e97d1 100644
--- a/sound/soc/codecs/max98390.c
+++ b/sound/soc/codecs/max98390.c
@@ -1067,6 +1067,9 @@ static int max98390_i2c_probe(struct i2c_client *i2c)
reset_gpio = devm_gpiod_get_optional(&i2c->dev,
"reset", GPIOD_OUT_HIGH);
+ if (IS_ERR(reset_gpio))
+ return dev_err_probe(&i2c->dev, PTR_ERR(reset_gpio),
+ "Failed to get reset gpio\n");
/* Power on device */
if (reset_gpio) {
--
2.25.1
Powered by blists - more mailing lists