ASoC: Intel: avs: fix possible memory leak in probe_codec()
Subsystems (3)
PATCH 1/1 ASoC: Intel: avs: fix possible memory leak in probe_codec()
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().
--- sound/soc/intel/avs/core.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/intel/avs/core.c +2 -0
@@ -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; }
Signature · 1 line
2.25.1
+Cc: Takashi Iwai <[email protected]>
Hi, is this patch good?
Thanks,
Yang
Quoted 24 lines · Yang Yingliang
If
snd_hda_codec_configure()fails, 'codec' and name allocated indev_set_name()called insnd_hdac_device_init()are leaked. Fix this by callingsnd_hdac_device_unregister()andput_device(), so they can be freed insnd_hda_codec_dev_release()andkobject_cleanup().Fixes 1affc44ea5dd ("ASoC: Intel: avs: PCI driver implementation")Signed-off-by Yang Yingliang <[email protected]>--- sound/soc/intel/avs/core.c | 2 ++ 1 file changed, 2 insertions(+)sound/soc/intel/avs/core.c +2
-0@@ -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; }
Quoted 4 lines · Yang Yingliang
+Cc: Takashi Iwai <[email protected]>
Hi, is this patch good?
Not really. The codec instances are freed later at avs_pci_remove().
Takashi
Quoted 29 lines
Thanks,
YangQuoted 24 lines · Yang Yingliang
If
snd_hda_codec_configure()fails, 'codec' and name allocated indev_set_name()called insnd_hdac_device_init()are leaked. Fix this by callingsnd_hdac_device_unregister()andput_device(), so they can be freed insnd_hda_codec_dev_release()andkobject_cleanup().Fixes 1affc44ea5dd ("ASoC: Intel: avs: PCI driver implementation")Signed-off-by Yang Yingliang <[email protected]>--- sound/soc/intel/avs/core.c | 2 ++ 1 file changed, 2 insertions(+)sound/soc/intel/avs/core.c +2
-0@@ -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; }