[PATCH 5/8] ASoC: soc-ac97: Fix error handling in snd_soc_new_ac97_component()

From: Amadeusz Sławiński

Date: Wed Oct 14 2026 - 16:13:37 EST


If call to snd_soc_ac97_init_gpio() fails, proper removal procedure
should mirror snd_soc_free_ac97_component() behaviour and call
device_del() before put_device().

Fixes: 9bf5c3d11f1f ("ASoC: ac97: add gpio chip")
Signed-off-by: Amadeusz Sławiński <amade@xxxxxxxxxx>
---
sound/soc/soc-ac97.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/soc/soc-ac97.c b/sound/soc/soc-ac97.c
index 5f81e3606655..5c573c8dc249 100644
--- a/sound/soc/soc-ac97.c
+++ b/sound/soc/soc-ac97.c
@@ -241,10 +241,12 @@ struct snd_ac97 *snd_soc_new_ac97_component(struct snd_soc_component *component,

ret = snd_soc_ac97_init_gpio(ac97, component);
if (ret)
- goto err_put_device;
+ goto err_del_device;

return ac97;

+err_del_device:
+ device_del(&ac97->dev);
err_put_device:
put_device(&ac97->dev);
return ERR_PTR(ret);
--
2.56.0