ALSA: emu8000: Fix a use after free in snd_emu8000_create_mixer
[sfrench/cifs-2.6.git] / sound / isa / sb / emu8000.c
index 0aa545ac6e60c1a62cd755ec3dd09f07bf887027..1c90421a88dcd74d4bed04c0f43bbe574226bf0a 100644 (file)
@@ -1029,8 +1029,10 @@ snd_emu8000_create_mixer(struct snd_card *card, struct snd_emu8000 *emu)
 
        memset(emu->controls, 0, sizeof(emu->controls));
        for (i = 0; i < EMU8000_NUM_CONTROLS; i++) {
-               if ((err = snd_ctl_add(card, emu->controls[i] = snd_ctl_new1(mixer_defs[i], emu))) < 0)
+               if ((err = snd_ctl_add(card, emu->controls[i] = snd_ctl_new1(mixer_defs[i], emu))) < 0) {
+                       emu->controls[i] = NULL;
                        goto __error;
+               }
        }
        return 0;