]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ALSA: sb: Fix potential double-free of CSP mixer elements
authorTakashi Iwai <tiwai@suse.de>
Tue, 8 Jun 2021 14:04:37 +0000 (16:04 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 20 Jul 2021 14:22:41 +0000 (16:22 +0200)
[ 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>
sound/isa/sb/sb16_csp.c

index 2cc068be7d3bee85dcdfacea52b54edc52b652f2..90fa57ad14c0486c5e752d8dce2f14169a3b56fb 100644 (file)
@@ -1086,10 +1086,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 */