Skip to content

Commit

Permalink
ALSA: ac97: fix possible memory leak in snd_ac97_dev_register()
Browse files Browse the repository at this point in the history
[ Upstream commit 4881bda ]

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: 0ca06a0 ("[ALSA] AC97 bus interface for ad-hoc drivers")
Signed-off-by: Yang Yingliang <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Takashi Iwai <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
Yang Yingliang authored and Sasha Levin committed Nov 3, 2022
1 parent 45ce9ed commit 2a20dee
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions sound/pci/ac97/ac97_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1965,6 +1965,7 @@ static int snd_ac97_dev_register(struct snd_device *device)
snd_ac97_get_short_name(ac97));
if ((err = device_register(&ac97->dev)) < 0) {
ac97_err(ac97, "Can't register ac97 bus\n");
put_device(&ac97->dev);
ac97->dev.bus = NULL;
return err;
}
Expand Down

0 comments on commit 2a20dee

Please sign in to comment.