Skip to content

Commit

Permalink
ALSA: usb-audio: Add check return value for usb_string()
Browse files Browse the repository at this point in the history
snd_usb_copy_string_desc() returns zero if usb_string() fails.
In case of failure, we need to check the snd_usb_copy_string_desc()'s
return value and add an exception case

Signed-off-by: Jaejoong Kim <climbbb.kim@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
jazzguitar81 authored and tiwai committed Dec 4, 2017
1 parent 251552a commit 89b89d1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions sound/usb/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2178,13 +2178,14 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid,
if (len)
;
else if (nameid)
snd_usb_copy_string_desc(state, nameid, kctl->id.name,
len = snd_usb_copy_string_desc(state, nameid, kctl->id.name,
sizeof(kctl->id.name));
else {
else
len = get_term_name(state, &state->oterm,
kctl->id.name, sizeof(kctl->id.name), 0);
if (!len)
strlcpy(kctl->id.name, "USB", sizeof(kctl->id.name));

if (!len) {
strlcpy(kctl->id.name, "USB", sizeof(kctl->id.name));

if (desc->bDescriptorSubtype == UAC2_CLOCK_SELECTOR)
append_ctl_name(kctl, " Clock Source");
Expand Down

0 comments on commit 89b89d1

Please sign in to comment.