aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2011-03-07 07:22:50 -0500
committerTakashi Iwai <tiwai@suse.de>2011-03-08 06:59:48 -0500
commit7c7335877105364f7f5181e80ff34206b54be81f (patch)
tree59d80caf4d634ff51765aa53dea8c4da4903e156 /sound
parentbdd3255d3adcb9f4fd70c09ec71eb1c5b36d833e (diff)
ALSA: control: fix numid conflict check for new controls
The purpose of the snd_ctl_hole_check() function is to find conflicts between the numerical IDs of the new control and those of any existing controls. However, it would fail to detect an existing control whose count is smaller than the new control's count and whose interval of IDs is entirely contained in the interval of the new control's IDs. To fix this, use the correct formula to detect overlapping intervals, which happens to simplify the condition. This problem was not encountered so far because ALSA does not yet allow drivers to allocate specific control IDs. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/core/control.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/sound/core/control.c b/sound/core/control.c
index 9ce00ed20fba..d1b5ce818a4f 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -285,10 +285,8 @@ static unsigned int snd_ctl_hole_check(struct snd_card *card,
285 struct snd_kcontrol *kctl; 285 struct snd_kcontrol *kctl;
286 286
287 list_for_each_entry(kctl, &card->controls, list) { 287 list_for_each_entry(kctl, &card->controls, list) {
288 if ((kctl->id.numid <= card->last_numid && 288 if (kctl->id.numid < card->last_numid + 1 + count &&
289 kctl->id.numid + kctl->count > card->last_numid) || 289 kctl->id.numid + kctl->count > card->last_numid + 1)
290 (kctl->id.numid <= card->last_numid + count - 1 &&
291 kctl->id.numid + kctl->count > card->last_numid + count - 1))
292 return card->last_numid = kctl->id.numid + kctl->count - 1; 290 return card->last_numid = kctl->id.numid + kctl->count - 1;
293 } 291 }
294 return card->last_numid; 292 return card->last_numid;