From: Jaejoong Kim <climbbb.kim@gmail.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: Jaroslav Kysela <perex@perex.cz>, stable <stable@vger.kernel.org>,
alsa-devel@alsa-project.org, Jaejoong Kim <climbbb.kim@gmail.com>
Subject: [PATCH 3/3] ALSA: usb-audio: Add check return value for usb_string()
Date: Tue, 28 Nov 2017 09:36:28 +0900 [thread overview]
Message-ID: <1511829388-5245-4-git-send-email-climbbb.kim@gmail.com> (raw)
In-Reply-To: <1511829388-5245-1-git-send-email-climbbb.kim@gmail.com>
snd_usb_copy_string_desc() returns a negative number 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>
---
sound/usb/mixer.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 8a434b7..3501eb5 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -2162,13 +2162,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,
- sizeof(kctl->id.name));
- else {
+ len = snd_usb_copy_string_desc(state, nameid, kctl->id.name,
+ sizeof(kctl->id.name));
+ else
len = get_term_name(state, &state->oterm,
kctl->id.name, sizeof(kctl->id.name), 0);
- if (len <= 0)
- strlcpy(kctl->id.name, "USB", sizeof(kctl->id.name));
+
+ if (len <= 0) {
+ strlcpy(kctl->id.name, "USB", sizeof(kctl->id.name));
if (desc->bDescriptorSubtype == UAC2_CLOCK_SELECTOR)
append_ctl_name(kctl, " Clock Source");
@@ -2177,7 +2178,6 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid,
else
append_ctl_name(kctl, " Playback Source");
}
-
usb_audio_dbg(state->chip, "[%d] SU [%s] items = %d\n",
cval->head.id, kctl->id.name, desc->bNrInPins);
return snd_usb_mixer_add_control(&cval->head, kctl);
--
2.7.4
next prev parent reply other threads:[~2017-11-28 0:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-28 0:36 [PATCH 0/3] ALSA: usb-audio: fix OOB and return value check Jaejoong Kim
2017-11-28 0:36 ` [PATCH 1/3] ALSA: usb-audio: Fix out-of-bound error Jaejoong Kim
2017-11-28 0:36 ` [PATCH 2/3] ALSA: usb-audio: Fix return value check for usb_string() Jaejoong Kim
2017-11-28 6:33 ` Takashi Iwai
2017-11-28 7:32 ` Jaejoong Kim
2017-11-28 0:36 ` Jaejoong Kim [this message]
2017-12-04 6:31 ` [PATCH V2 0/2] ALSA: usb-audio: fix OOB and return value check Jaejoong Kim
2017-12-04 6:31 ` [PATCH V2 1/2] ALSA: usb-audio: Fix out-of-bound error Jaejoong Kim
2017-12-04 8:18 ` Takashi Iwai
2017-12-04 6:31 ` [PATCH V2 2/2] ALSA: usb-audio: Add check return value for usb_string() Jaejoong Kim
2017-12-04 8:18 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1511829388-5245-4-git-send-email-climbbb.kim@gmail.com \
--to=climbbb.kim@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=perex@perex.cz \
--cc=stable@vger.kernel.org \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).