If snd_hdac_device_register() fails, 'codec' is leaked, free it in snd_hdac_device_exit(). And device_initialize() is called in snd_hdac_device_init(), it should call put_device() to give up reference or the name allocated in dev_set_name() is leaked. The snd_hdac_device_exit() will be called in dev->release(). Fixes: e4746d94d00c ("ASoC: Intel: Skylake: Introduce HDA codec init and exit routines") Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx> --- sound/soc/intel/skylake/skl.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c index bbba2df33aaf..f0048e3fa619 100644 --- a/sound/soc/intel/skylake/skl.c +++ b/sound/soc/intel/skylake/skl.c @@ -691,7 +691,11 @@ static void load_codec_module(struct hda_codec *codec) static void skl_codec_device_exit(struct device *dev) { - snd_hdac_device_exit(dev_to_hdac_dev(dev)); + struct hdac_device *hdac_dev = dev_to_hdac_dev(dev); + struct hda_codec *codec = container_of(hdac_dev, struct hda_codec, core); + + snd_hdac_device_exit(hdac_dev); + kfree(codec); } static struct hda_codec *skl_codec_device_init(struct hdac_bus *bus, int addr) @@ -711,7 +715,7 @@ static struct hda_codec *skl_codec_device_init(struct hdac_bus *bus, int addr) ret = snd_hdac_device_register(&codec->core); if (ret) { dev_err(bus->dev, "failed to register hdac device\n"); - snd_hdac_device_exit(&codec->core); + put_device(&codec->core.dev); return ERR_PTR(ret); } -- 2.25.1