Skip to content

Commit e944167

Browse files
Yang Yingliangbroonie
authored andcommitted
ASoC: SOF: Intel: hda-codec: fix possible memory leak in hda_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: 829c673 ("ASoC: SOF: Intel: Introduce HDA codec init and exit routines") Fixes: dfe66a1 ("ALSA: hdac_ext: add extended HDA bus") Signed-off-by: Yang Yingliang <[email protected]> Reviewed-by: Kai Vehmanen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent a75481f commit e944167

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

sound/soc/sof/intel/hda-codec.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,6 @@ EXPORT_SYMBOL_NS(hda_codec_jack_check, SND_SOC_SOF_HDA_AUDIO_CODEC);
109109
#define is_generic_config(x) 0
110110
#endif
111111

112-
static void hda_codec_device_exit(struct device *dev)
113-
{
114-
snd_hdac_device_exit(dev_to_hdac_dev(dev));
115-
}
116-
117112
static struct hda_codec *hda_codec_device_init(struct hdac_bus *bus, int addr, int type)
118113
{
119114
struct hda_codec *codec;
@@ -126,12 +121,11 @@ static struct hda_codec *hda_codec_device_init(struct hdac_bus *bus, int addr, i
126121
}
127122

128123
codec->core.type = type;
129-
codec->core.dev.release = hda_codec_device_exit;
130124

131125
ret = snd_hdac_device_register(&codec->core);
132126
if (ret) {
133127
dev_err(bus->dev, "failed to register hdac device\n");
134-
snd_hdac_device_exit(&codec->core);
128+
put_device(&codec->core.dev);
135129
return ERR_PTR(ret);
136130
}
137131

0 commit comments

Comments
 (0)