Skip to content

Commit d09c06c

Browse files
committed
ALSA: usb-audio - Fix possible access over audio_feature_info[] array
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>
1 parent e653510 commit d09c06c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎sound/usb/mixer.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,7 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid, void
12591259
build_feature_ctl(state, _ftr, 0, i, &iterm, unitid, 0);
12601260
}
12611261
} else { /* UAC_VERSION_2 */
1262-
for (i = 0; i < 30/2; i++) {
1262+
for (i = 0; i < ARRAY_SIZE(audio_feature_info); i++) {
12631263
unsigned int ch_bits = 0;
12641264
unsigned int ch_read_only = 0;
12651265

0 commit comments

Comments
 (0)