summaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-06-26 00:59:57 -0400
committerTakashi Iwai <tiwai@suse.de>2015-06-26 00:59:57 -0400
commit7378bc2f19f841b25f1e27c7abce1ecc298f71f1 (patch)
tree8b79256e1f51cee31805bcc210d2bd39811662dd /sound
parent650474fb737c3e0ea0f6ab8e43c2cd161080ce5c (diff)
ALSA: jack: Fix endless loop at unique index detection
While the commit [d0a601c278de: ALSA: jack: Fix the id uniqueness check] fixes the wrong string check, it leads to a worse result -- the loop in get_available_index() goes into an endless loop. The cause is that snd_ctl_find_id() returns the object assigned to the numid if it's set. Thus it points to the previous entry again. This patch clears the numid field for the next call properly. Reported-and-tested-by: Tomáš Pružina <pruzinat@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/core/ctljack.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sound/core/ctljack.c b/sound/core/ctljack.c
index 9149a4aefa95..84a3cd683068 100644
--- a/sound/core/ctljack.c
+++ b/sound/core/ctljack.c
@@ -41,8 +41,11 @@ static int get_available_index(struct snd_card *card, const char *name)
41 sid.iface = SNDRV_CTL_ELEM_IFACE_CARD; 41 sid.iface = SNDRV_CTL_ELEM_IFACE_CARD;
42 strlcpy(sid.name, name, sizeof(sid.name)); 42 strlcpy(sid.name, name, sizeof(sid.name));
43 43
44 while (snd_ctl_find_id(card, &sid)) 44 while (snd_ctl_find_id(card, &sid)) {
45 sid.index++; 45 sid.index++;
46 /* reset numid; otherwise snd_ctl_find_id() hits this again */
47 sid.numid = 0;
48 }
46 49
47 return sid.index; 50 return sid.index;
48} 51}