Skip to contentSkip to conversation

ALSA: pcm: Fix incorrect numerator selection in snd_interval_ratden()

PATCH Applied Sreeraj S Kurup 2 participants 3 messages Nov 20 – Nov 21 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: pcm: Fix incorrect numerator selection in snd_interval_ratden()

When the calculated numerator is smaller than num_min, the function incorrectly sets it to num_max instead of num_min.

This can produce an invalid interval by making the calculated minimum numerator larger than the maximum numerator, even when a valid range exists.

Set the numerator to num_min when it falls below the minimum allowed value. This allows the function to calculate the correct lower bound and prevents valid intervals from being rejected.

---
 sound/core/pcm_lib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/pcm_lib.c +1 -1
index bb16738bb591..65c7472ef22e 100644
@@ -966,7 +966,7 @@ static int snd_interval_ratden(struct snd_interval *i,
 		if (num > rats[k].num_max)
 			continue;
 		if (num < rats[k].num_min)
-			num = rats[k].num_max;
+			num = rats[k].num_min;
 		else {
 			unsigned int r;
 			r = (num - rats[k].num_min) % rats[k].num_step;
Signature · 1 line
2.55.0
Applied
#1 lore raw
Quoted 8 lines · Sreeraj S Kurup

When the calculated numerator is smaller than num_min, the function incorrectly sets it to num_max instead of num_min.

This can produce an invalid interval by making the calculated minimum numerator larger than the maximum numerator, even when a valid range exists.

Quoted 5 lines

Set the numerator to num_min when it falls below the minimum allowed value. This allows the function to calculate the correct lower bound and prevents valid intervals from being rejected.

Applied to for-next branch. Thanks.

Takashi