Commit 4881bda5 authored by Yang Yingliang's avatar Yang Yingliang Committed by Takashi Iwai

ALSA: ac97: fix possible memory leak in snd_ac97_dev_register()

If device_register() fails in snd_ac97_dev_register(), it should
call put_device() to give up reference, or the name allocated in
dev_set_name() is leaked.

Fixes: 0ca06a00 ("[ALSA] AC97 bus interface for ad-hoc drivers")
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20221019093025.1179475-1-yangyingliang@huawei.comSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 491a4ccd
......@@ -2009,6 +2009,7 @@ static int snd_ac97_dev_register(struct snd_device *device)
err = device_register(&ac97->dev);
if (err < 0) {
ac97_err(ac97, "Can't register ac97 bus\n");
put_device(&ac97->dev);
ac97->dev.bus = NULL;
return err;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment