Skip to content

Commit

Permalink
ALSA: jack: Fix endless loop at unique index detection
Browse files Browse the repository at this point in the history
While the commit [d0a601c: 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>
  • Loading branch information
Takashi Iwai committed Jun 26, 2015
1 parent 650474f commit 7378bc2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sound/core/ctljack.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ static int get_available_index(struct snd_card *card, const char *name)
sid.iface = SNDRV_CTL_ELEM_IFACE_CARD;
strlcpy(sid.name, name, sizeof(sid.name));

while (snd_ctl_find_id(card, &sid))
while (snd_ctl_find_id(card, &sid)) {
sid.index++;
/* reset numid; otherwise snd_ctl_find_id() hits this again */
sid.numid = 0;
}

return sid.index;
}
Expand Down

0 comments on commit 7378bc2

Please sign in to comment.