ALSA: asihpi - Fix potential Oops in snd_asihpi_cmode_info()
authorTakashi Iwai <tiwai@suse.de>
Mon, 9 Jan 2012 17:26:05 +0000 (18:26 +0100)
committerTakashi Iwai <tiwai@suse.de>
Mon, 9 Jan 2012 17:27:54 +0000 (18:27 +0100)
Dan Carpenter reported that setting 0 to uinfo->value.enumerated.items
in snd_asihpi_cmode_info() may lead to Oops.  This function should
return an error immediately in such a case instead.

Cc: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/asihpi/asihpi.c

index fd3926fb0a082321a828581fec36b41ad89aba40..e8de831f98bc510c6cde42159bce817dad45408b 100644 (file)
@@ -2259,6 +2259,9 @@ static int snd_asihpi_cmode_info(struct snd_kcontrol *kcontrol,
                        valid_modes++;
                        }
 
+       if (!valid_modes)
+               return -EINVAL;
+
        uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
        uinfo->count = 1;
        uinfo->value.enumerated.items = valid_modes;