diff options
| author | Chen Ni <nichen@iscas.ac.cn> | 2026-01-30 17:19:04 +0800 |
|---|---|---|
| committer | Sasha Levin <sashal@kernel.org> | 2026-03-04 07:20:24 -0500 |
| commit | 7131ea3dbdf342e7e2a3ce7fc38594a0be59e2a4 (patch) | |
| tree | b95c1e19e7566b7bdb61619f0f1d37f7c27ea505 | |
| parent | 138138329a0a60e2509c8346ca11778808cb7baf (diff) | |
ASoC: codecs: max98390: Check return value of devm_gpiod_get_optional() in max98390_i2c_probe()
[ Upstream commit a1d14d8364eac2611fe1391c73ff0e5b26064f0e ]
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@iscas.ac.cn>
Link: https://patch.msgid.link/20260130091904.3426149-1-nichen@iscas.ac.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
| -rw-r--r-- | sound/soc/codecs/max98390.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/sound/soc/codecs/max98390.c b/sound/soc/codecs/max98390.c index 7a5260ff8d6b..09fae6ee2b44 100644 --- a/sound/soc/codecs/max98390.c +++ b/sound/soc/codecs/max98390.c @@ -1076,6 +1076,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) { |
