Skip to contentSkip to conversation

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

PATCH Applied Yang Yingliang 2 participants 2 messages Oct 19, 2022 – Oct 20, 2022 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 sound/pci/ac97/ac97_codec.c | 1 +
 1 file changed, 1 insertion(+)
sound/pci/ac97/ac97_codec.c +1 -0
index cb60a07d39a8..ceead55f13ab 100644
@@ -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;
 	}
Signature · 1 line
2.25.1
Applied
#1 lore raw
Quoted 7 lines · Yang Yingliang

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")

Thanks, applied.

Takashi