Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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@iscas.ac.cn>
Link: https://patch.msgid.link/20260130091904.3426149-1-nichen@iscas.ac.cn
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Chen Ni and committed by
Mark Brown
a1d14d83 bbb758a6

+3
+3
sound/soc/codecs/max98390.c
··· 1067 1067 1068 1068 reset_gpio = devm_gpiod_get_optional(&i2c->dev, 1069 1069 "reset", GPIOD_OUT_HIGH); 1070 + if (IS_ERR(reset_gpio)) 1071 + return dev_err_probe(&i2c->dev, PTR_ERR(reset_gpio), 1072 + "Failed to get reset gpio\n"); 1070 1073 1071 1074 /* Power on device */ 1072 1075 if (reset_gpio) {