Skip to content

Commit 54a032d

Browse files
MrVanbroonie
authored andcommitted
ASoC: pxa2xx-ac97: fix error handling for reset GPIO descriptor
The reset GPIO obtained via devm_gpiod_get() may return an ERR_PTR() when the GPIO is missing or an error occurs. The current code unconditionally assigns PTR_ERR() to ret and later dereferences rst_gpio via desc_to_gpio(), which is incorrect when rst_gpio is an error pointer. Rework the logic to first check IS_ERR(rst_gpio) before converting the descriptor. Handle -ENOENT by disabling reset GPIO support, and return other errors to the caller as expected. Fixes: c76d50b ("ASoC: ac97: Convert to GPIO descriptors") Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <error27@gmail.com> Closes: https://lore.kernel.org/r/202604041426.i2C1xqHk-lkp@intel.com/ Signed-off-by: Peng Fan <peng.fan@nxp.com> Link: https://patch.msgid.link/20260413-ac97-v1-1-b44b9e084307@nxp.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent bc9b1eb commit 54a032d

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

sound/arm/pxa2xx-ac97-lib.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,15 @@ int pxa2xx_ac97_hw_probe(struct platform_device *dev)
331331
if (dev->dev.of_node) {
332332
/* Assert reset using GPIOD_OUT_HIGH, because reset is GPIO_ACTIVE_LOW */
333333
rst_gpio = devm_gpiod_get(&dev->dev, "reset", GPIOD_OUT_HIGH);
334-
ret = PTR_ERR(rst_gpio);
335-
if (ret == -ENOENT)
336-
reset_gpio = -1;
337-
else if (ret)
338-
return ret;
339-
reset_gpio = desc_to_gpio(rst_gpio);
334+
if (IS_ERR(rst_gpio)) {
335+
ret = PTR_ERR(rst_gpio);
336+
if (ret == -ENOENT)
337+
reset_gpio = -1;
338+
else if (ret)
339+
return ret;
340+
} else {
341+
reset_gpio = desc_to_gpio(rst_gpio);
342+
}
340343
} else {
341344
if (cpu_is_pxa27x())
342345
reset_gpio = 113;

0 commit comments

Comments
 (0)