Skip to content

Commit

Permalink
ALSA: usb-audio - Fix possible access over audio_feature_info[] array
Browse files Browse the repository at this point in the history
The audio_feature_info[] array should contain all entries for UAC2_FU_*,
but currently a few last entries are missing.  Even though, the driver
tries to probe these entries in parse_audio_feature_unit() and may
access the range over the array.  This patch fixes the bug by limiting
the loop size properly using ARRAY_SIZE() instead of a hard-coded
magic number.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Takashi Iwai committed Oct 13, 2011
1 parent e653510 commit d09c06c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sound/usb/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void
build_feature_ctl(state, _ftr, 0, i, &iterm, unitid, 0);
}
} else { /* UAC_VERSION_2 */
for (i = 0; i < 30/2; i++) {
for (i = 0; i < ARRAY_SIZE(audio_feature_info); i++) {
unsigned int ch_bits = 0;
unsigned int ch_read_only = 0;

Expand Down

0 comments on commit d09c06c

Please sign in to comment.