Commit be22db77 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: usb-audio: Fix uninitialized variable at __uac_clock_find_source()

The cur variable indicating the currently selected clock source can be
theoretically used as uninitialized after the recent commit
481f17c4 ("ALSA: usb-audio: Handle error for the current selector
gracefully").  For addressing it, initialize it before use.

Also, one place seems setting 0 to a wrong variable ret, instead of
cur; otherwise it makes little sense.  Since the initialization is
done beforehand, we can get rid of this line, too.

Fixes: 481f17c4 ("ALSA: usb-audio: Handle error for the current selector gracefully")
Reported-by: default avatarColin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/4b261d68-f53f-240d-2d8a-2f88b337849d@canonical.com
Link: https://lore.kernel.org/r/s5hfsyhh97t.wl-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent bdaedca7
...@@ -290,6 +290,7 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip, ...@@ -290,6 +290,7 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
pins = GET_VAL(selector, proto, bNrInPins); pins = GET_VAL(selector, proto, bNrInPins);
clock_id = GET_VAL(selector, proto, bClockID); clock_id = GET_VAL(selector, proto, bClockID);
sources = GET_VAL(selector, proto, baCSourceID); sources = GET_VAL(selector, proto, baCSourceID);
cur = 0;
if (pins == 1) { if (pins == 1) {
ret = 1; ret = 1;
...@@ -314,7 +315,6 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip, ...@@ -314,7 +315,6 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
if (!chip->autoclock) if (!chip->autoclock)
return -EINVAL; return -EINVAL;
ret = 0;
goto find_others; goto find_others;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment