X-Git-Url: https://git.stricted.de/?a=blobdiff_plain;f=sound%2Fusb%2Fformat.c;h=e09aba19375cf938eafd28aedec9edf2ea55dbbe;hb=8c3f5d8a9b7d0d8506bc2a0525e012eae02b1853;hp=89421d176570739c6034c70a3cdd74285a5f394e;hpb=6681ba7ec480bc839584fd0817991d248b4b9e44;p=GitHub%2Fmt8127%2Fandroid_kernel_alcatel_ttab.git diff --git a/sound/usb/format.c b/sound/usb/format.c index 89421d176570..e09aba19375c 100644 --- a/sound/usb/format.c +++ b/sound/usb/format.c @@ -209,6 +209,8 @@ static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audiof return 0; } +#define MAX_UAC2_NR_RATES 1024 + /* * Helper function to walk the array of sample rate triplets reported by * the device. The problem is that we need to parse whole array first to @@ -226,7 +228,7 @@ static int parse_uac2_sample_rate_range(struct audioformat *fp, int nr_triplets, int min = combine_quad(&data[2 + 12 * i]); int max = combine_quad(&data[6 + 12 * i]); int res = combine_quad(&data[10 + 12 * i]); - int rate; + unsigned int rate; if ((max < 0) || (min < 0) || (res < 0) || (max < min)) continue; @@ -253,6 +255,10 @@ static int parse_uac2_sample_rate_range(struct audioformat *fp, int nr_triplets, fp->rates |= snd_pcm_rate_to_rate_bit(rate); nr_rates++; + if (nr_rates >= MAX_UAC2_NR_RATES) { + snd_printk(KERN_ERR "invalid uac2 rates\n"); + break; + } /* avoid endless loop */ if (res == 0)