diff options
author | Takashi Iwai <tiwai@suse.de> | 2021-06-08 17:04:37 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-07-20 17:05:42 +0300 |
commit | 0e54f8ee6bff85def622bfa29f74569fb824536a (patch) | |
tree | 94d4e32acb12e293d71301761245f90d2df63f8e /sound/isa | |
parent | 52d242f2bffef61e6c3bbc7ebbf41c4bf7b010d0 (diff) | |
download | linux-0e54f8ee6bff85def622bfa29f74569fb824536a.tar.xz |
ALSA: sb: Fix potential double-free of CSP mixer elements
[ Upstream commit c305366a37441c2ac90b08711cb6f032b43672f2 ]
snd_sb_qsound_destroy() contains the calls of removing the previously
created mixer controls, but it doesn't clear the pointers. As
snd_sb_qsound_destroy() itself may be repeatedly called via ioctl,
this could lead to double-free potentially.
Fix it by clearing the struct fields properly afterwards.
Link: https://lore.kernel.org/r/20210608140540.17885-4-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'sound/isa')
-rw-r--r-- | sound/isa/sb/sb16_csp.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c index 1528e04a4d28..dbcd9ab2c2b7 100644 --- a/sound/isa/sb/sb16_csp.c +++ b/sound/isa/sb/sb16_csp.c @@ -1072,10 +1072,14 @@ static void snd_sb_qsound_destroy(struct snd_sb_csp * p) card = p->chip->card; down_write(&card->controls_rwsem); - if (p->qsound_switch) + if (p->qsound_switch) { snd_ctl_remove(card, p->qsound_switch); - if (p->qsound_space) + p->qsound_switch = NULL; + } + if (p->qsound_space) { snd_ctl_remove(card, p->qsound_space); + p->qsound_space = NULL; + } up_write(&card->controls_rwsem); /* cancel pending transfer of QSound parameters */ |