[PATCH] ALSA: hda: fix possible memory leak in azx_codec_configure()
Yang Yingliang
yangyingliang at huawei.com
Mon Oct 24 14:26:46 CEST 2022
If the codec device is registered, after calling snd_hdac_device_unregister(),
codec has already been removed from chip bus, it should call put_device() to
give up reference to free codec and device name.
Fixes: c0f1886de7e1 ("ALSA: hda: intel: Allow repeatedly probing on codec configuration errors")
Signed-off-by: Yang Yingliang <yangyingliang at huawei.com>
---
sound/pci/hda/hda_controller.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c
index 0ff286b7b66b..f6a73ce300a4 100644
--- a/sound/pci/hda/hda_controller.c
+++ b/sound/pci/hda/hda_controller.c
@@ -1257,8 +1257,11 @@ int azx_codec_configure(struct azx *chip)
/* unregister failed codecs if any codec has been probed */
list_for_each_codec_safe(codec, next, &chip->bus) {
if (!codec->configured) {
+ bool is_registered = device_is_registered(&codec->core.dev);
codec_err(codec, "Unable to configure, disabling\n");
snd_hdac_device_unregister(&codec->core);
+ if (is_registered)
+ put_device(&codec->core.dev);
}
}
}
--
2.25.1
More information about the Alsa-devel
mailing list