* [PATCH] ALSA: ac97: fix possible memory leak in snd_ac97_dev_register()
@ 2022-10-19 9:30 Yang Yingliang
2022-10-20 12:20 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Yang Yingliang @ 2022-10-19 9:30 UTC (permalink / raw)
To: alsa-devel; +Cc: liam.girdwood, yangyingliang, nico, tiwai
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>
---
sound/pci/ac97/ac97_codec.c | 1 +
1 file changed, 1 insertion(+)
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;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-20 12:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-19 9:30 [PATCH] ALSA: ac97: fix possible memory leak in snd_ac97_dev_register() Yang Yingliang
2022-10-20 12:20 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox