* [PATCH] ASoC: Intel: avs: fix possible memory leak in probe_codec()
@ 2022-10-22 2:58 Yang Yingliang
2022-11-02 1:48 ` Yang Yingliang
0 siblings, 1 reply; 3+ messages in thread
From: Yang Yingliang @ 2022-10-22 2:58 UTC (permalink / raw)
To: alsa-devel; +Cc: yangyingliang, cezary.rojewski, broonie, amadeuszx.slawinski
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@huawei.com>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: Intel: avs: fix possible memory leak in probe_codec()
2022-10-22 2:58 [PATCH] ASoC: Intel: avs: fix possible memory leak in probe_codec() Yang Yingliang
@ 2022-11-02 1:48 ` Yang Yingliang
2022-11-02 6:36 ` Takashi Iwai
0 siblings, 1 reply; 3+ messages in thread
From: Yang Yingliang @ 2022-11-02 1:48 UTC (permalink / raw)
To: alsa-devel
Cc: Takashi Iwai, yangyingliang, cezary.rojewski, broonie,
amadeuszx.slawinski
+Cc: Takashi Iwai <tiwai@suse.de>
Hi, is this patch good?
Thanks,
Yang
On 2022/10/22 10:58, Yang Yingliang wrote:
> 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@huawei.com>
> ---
> 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;
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: Intel: avs: fix possible memory leak in probe_codec()
2022-11-02 1:48 ` Yang Yingliang
@ 2022-11-02 6:36 ` Takashi Iwai
0 siblings, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2022-11-02 6:36 UTC (permalink / raw)
To: Yang Yingliang; +Cc: alsa-devel, broonie, cezary.rojewski, amadeuszx.slawinski
On Wed, 02 Nov 2022 02:48:30 +0100,
Yang Yingliang wrote:
>
> +Cc: Takashi Iwai <tiwai@suse.de>
>
> Hi, is this patch good?
Not really. The codec instances are freed later at avs_pci_remove().
Takashi
>
> Thanks,
> Yang
> On 2022/10/22 10:58, Yang Yingliang wrote:
> > 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@huawei.com>
> > ---
> > 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;
> > }
> >
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-11-02 6:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-22 2:58 [PATCH] ASoC: Intel: avs: fix possible memory leak in probe_codec() Yang Yingliang
2022-11-02 1:48 ` Yang Yingliang
2022-11-02 6:36 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox