summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorYang Yingliang <yangyingliang@huawei.com>2022-10-19 12:30:25 +0300
committerTakashi Iwai <tiwai@suse.de>2022-10-20 15:19:48 +0300
commit4881bda5ea05c8c240fc8afeaa928e2bc43f61fa (patch)
treeaf286aa6742c49fbe406e73f06ba4b2dedd15e02 /sound
parent491a4ccd8a0258392900c80c6b2b622c7115fc23 (diff)
downloadlinux-4881bda5ea05c8c240fc8afeaa928e2bc43f61fa.tar.xz
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: 0ca06a00e206 ("[ALSA] AC97 bus interface for ad-hoc drivers") Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Link: https://lore.kernel.org/r/20221019093025.1179475-1-yangyingliang@huawei.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/pci/ac97/ac97_codec.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index cb60a07d39a8..ceead55f13ab 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -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;
}