ALSA: emu10k1: add error handling for snd_ctl_add
authorZhouyang Jia <jiazhouyang09@gmail.com>
Mon, 11 Jun 2018 08:18:40 +0000 (16:18 +0800)
committerTakashi Iwai <tiwai@suse.de>
Mon, 11 Jun 2018 13:23:00 +0000 (15:23 +0200)
When snd_ctl_add fails, the lack of error-handling code may
cause unexpected results.

This patch adds error-handling code after calling snd_ctl_add.

Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/emu10k1/emupcm.c

index d39458ab251fb0685e28993f2c89b2505dc6174c..69f9b100bd24c12e834378006e5649f6b668aedb 100644 (file)
@@ -1858,7 +1858,9 @@ int snd_emu10k1_pcm_efx(struct snd_emu10k1 *emu, int device)
        if (!kctl)
                return -ENOMEM;
        kctl->id.device = device;
-       snd_ctl_add(emu->card, kctl);
+       err = snd_ctl_add(emu->card, kctl);
+       if (err < 0)
+               return err;
 
        snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024);