Skip to content

Commit 0e21381

Browse files
Yang Yingliangbroonie
authored andcommitted
ASoC: Intel: Skylake: fix possible memory leak in skl_codec_device_init()
If snd_hdac_device_register() fails, 'codec' and name allocated in dev_set_name() called in snd_hdac_device_init() are leaked. Fix this by calling put_device(), so they can be freed in snd_hda_codec_dev_release() and kobject_cleanup(). Fixes: e4746d9 ("ASoC: Intel: Skylake: Introduce HDA codec init and exit routines") Signed-off-by: Yang Yingliang <[email protected]> Suggested-by: Cezary Rojewski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 05de5cf commit 0e21381

File tree

1 file changed

+1
-7
lines changed
  • sound/soc/intel/skylake

1 file changed

+1
-7
lines changed

sound/soc/intel/skylake/skl.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -689,11 +689,6 @@ static void load_codec_module(struct hda_codec *codec)
689689

690690
#endif /* CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC */
691691

692-
static void skl_codec_device_exit(struct device *dev)
693-
{
694-
snd_hdac_device_exit(dev_to_hdac_dev(dev));
695-
}
696-
697692
static struct hda_codec *skl_codec_device_init(struct hdac_bus *bus, int addr)
698693
{
699694
struct hda_codec *codec;
@@ -706,12 +701,11 @@ static struct hda_codec *skl_codec_device_init(struct hdac_bus *bus, int addr)
706701
}
707702

708703
codec->core.type = HDA_DEV_ASOC;
709-
codec->core.dev.release = skl_codec_device_exit;
710704

711705
ret = snd_hdac_device_register(&codec->core);
712706
if (ret) {
713707
dev_err(bus->dev, "failed to register hdac device\n");
714-
snd_hdac_device_exit(&codec->core);
708+
put_device(&codec->core.dev);
715709
return ERR_PTR(ret);
716710
}
717711

0 commit comments

Comments
 (0)