提交 7c733587 编写于 作者: C Clemens Ladisch 提交者: Takashi Iwai

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: NClemens Ladisch <clemens@ladisch.de>
Signed-off-by: NTakashi Iwai <tiwai@suse.de>
上级 bdd3255d
...@@ -285,10 +285,8 @@ static unsigned int snd_ctl_hole_check(struct snd_card *card, ...@@ -285,10 +285,8 @@ static unsigned int snd_ctl_hole_check(struct snd_card *card,
struct snd_kcontrol *kctl; struct snd_kcontrol *kctl;
list_for_each_entry(kctl, &card->controls, list) { list_for_each_entry(kctl, &card->controls, list) {
if ((kctl->id.numid <= card->last_numid && if (kctl->id.numid < card->last_numid + 1 + count &&
kctl->id.numid + kctl->count > card->last_numid) || kctl->id.numid + kctl->count > card->last_numid + 1)
(kctl->id.numid <= card->last_numid + count - 1 &&
kctl->id.numid + kctl->count > card->last_numid + count - 1))
return card->last_numid = kctl->id.numid + kctl->count - 1; return card->last_numid = kctl->id.numid + kctl->count - 1;
} }
return card->last_numid; return card->last_numid;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册