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

Yang Yingliang yangyingliang at huawei.com
Wed Nov 2 02:48:30 CET 2022


+Cc: Takashi Iwai <tiwai at 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 at 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;
>   	}
>   


More information about the Alsa-devel mailing list