Return-Path: Received: from mail-cys01nam02on0092.outbound.protection.outlook.com ([104.47.37.92]:7188 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932171AbeARVDl (ORCPT ); Thu, 18 Jan 2018 16:03:41 -0500 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: Jaejoong Kim , Takashi Iwai , "Sasha Levin" Subject: [added to the 4.1 stable tree] ALSA: usb-audio: Add check return value for usb_string() Date: Thu, 18 Jan 2018 21:00:48 +0000 Message-ID: <20180118205908.3220-159-alexander.levin@microsoft.com> References: <20180118205908.3220-1-alexander.levin@microsoft.com> In-Reply-To: <20180118205908.3220-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Jaejoong Kim This patch has been added to the stable tree. If you have any objections, please let us know. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [ Upstream commit 89b89d121ffcf8d9546633b98ded9d18b8f75891 ] 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 Cc: Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/usb/mixer.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 332cfeee4cb1..2ee449fbe55f 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -2100,13 +2100,14 @@ static int parse_audio_selector_unit(struct mixer_b= uild *state, int unitid, if (len) ; else if (nameid) - snd_usb_copy_string_desc(state, nameid, kctl->id.name, + len =3D snd_usb_copy_string_desc(state, nameid, kctl->id.name, sizeof(kctl->id.name)); - else { + else len =3D 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)); =20 if (desc->bDescriptorSubtype =3D=3D UAC2_CLOCK_SELECTOR) append_ctl_name(kctl, " Clock Source"); --=20 2.11.0