[PATCH] ASoC: Intel: avs: fix possible memory leak in probe_codec()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If snd_hda_codec_configure() fails, 'codec' and name allocated in
dev_set_name() called in snd_hdac_device_init() are leaked. Fix this
by calling snd_hdac_device_unregister() and put_device(), so they
can be freed in snd_hda_codec_dev_release() and kobject_cleanup().

Fixes: 1affc44ea5dd ("ASoC: Intel: avs: PCI driver implementation")
Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx>
---
 sound/soc/intel/avs/core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sound/soc/intel/avs/core.c b/sound/soc/intel/avs/core.c
index bb0719c58ca4..2fde2b3f8790 100644
--- a/sound/soc/intel/avs/core.c
+++ b/sound/soc/intel/avs/core.c
@@ -140,6 +140,8 @@ static int probe_codec(struct hdac_bus *bus, int addr)
 	ret = snd_hda_codec_configure(codec);
 	if (ret < 0) {
 		dev_err(bus->dev, "failed to config codec %d\n", ret);
+		snd_hdac_device_unregister(&codec->core);
+		put_device(&codec->core.dev);
 		return ret;
 	}
 
-- 
2.25.1




[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux