Skip to content

Commit

Permalink
ALSA: asihpi - Fix potential Oops in snd_asihpi_cmode_info()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Takashi Iwai committed Jan 9, 2012
1 parent 9badda0 commit 74eeb14
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sound/pci/asihpi/asihpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 74eeb14

Please sign in to comment.