Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 284139
b: refs/heads/master
c: 4fa0e81
h: refs/heads/master
i:
  284137: e48541d
  284135: a52baef
v: v3
  • Loading branch information
Xi Wang authored and Takashi Iwai committed Jan 8, 2012
1 parent c3d13ce commit cf808b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: fb65c2dfe60d38be6b9193d0b85e66e780cd4373
refs/heads/master: 4fa0e81b83503900be277e6273a79651b375e288
8 changes: 7 additions & 1 deletion trunk/sound/usb/format.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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)
Expand Down

0 comments on commit cf808b6

Please sign in to comment.