aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb/format.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/usb/format.c')
-rw-r--r--sound/usb/format.c8
1 files changed, 7 insertions, 1 deletions
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
209 return 0; 209 return 0;
210} 210}
211 211
212#define MAX_UAC2_NR_RATES 1024
213
212/* 214/*
213 * Helper function to walk the array of sample rate triplets reported by 215 * Helper function to walk the array of sample rate triplets reported by
214 * the device. The problem is that we need to parse whole array first to 216 * 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,
226 int min = combine_quad(&data[2 + 12 * i]); 228 int min = combine_quad(&data[2 + 12 * i]);
227 int max = combine_quad(&data[6 + 12 * i]); 229 int max = combine_quad(&data[6 + 12 * i]);
228 int res = combine_quad(&data[10 + 12 * i]); 230 int res = combine_quad(&data[10 + 12 * i]);
229 int rate; 231 unsigned int rate;
230 232
231 if ((max < 0) || (min < 0) || (res < 0) || (max < min)) 233 if ((max < 0) || (min < 0) || (res < 0) || (max < min))
232 continue; 234 continue;
@@ -253,6 +255,10 @@ static int parse_uac2_sample_rate_range(struct audioformat *fp, int nr_triplets,
253 fp->rates |= snd_pcm_rate_to_rate_bit(rate); 255 fp->rates |= snd_pcm_rate_to_rate_bit(rate);
254 256
255 nr_rates++; 257 nr_rates++;
258 if (nr_rates >= MAX_UAC2_NR_RATES) {
259 snd_printk(KERN_ERR "invalid uac2 rates\n");
260 break;
261 }
256 262
257 /* avoid endless loop */ 263 /* avoid endless loop */
258 if (res == 0) 264 if (res == 0)