Received: by 10.223.185.116 with SMTP id b49csp1026235wrg; Wed, 21 Feb 2018 10:47:39 -0800 (PST) X-Google-Smtp-Source: AH8x227IRUmnuvQ1mBwO/7MQEuXdqqWsC91IcIVrLCodqK6cD0bbSSBFRy9naJ4T+T8JZvOol2Ed X-Received: by 2002:a17:902:ab89:: with SMTP id f9-v6mr3390811plr.369.1519238859676; Wed, 21 Feb 2018 10:47:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519238859; cv=none; d=google.com; s=arc-20160816; b=SQx4KX2hZWXxwealtcR2BA7FQTTG6SJVD3MsyepsIHriX9jxwA0guSYTSSll6WFXsA 0r2MxbFWvHin2jtb9UL/uGv4kRTUFWMKY71dWHaCh+giI35x0GsPXN60ekQeKDk9Muaf ODCImgSZgijU0fBp6h1qRQ6frKMMsl2P/YdtSOAh9fqRI+co6FsmITYMT913JODn2rRz 7n+W+ZNnyGJwR0GTVZvYdURvDYpcJmBGp64QusFYflA3DzZ6c+snkHF7KR9TkpY0H905 4F9uKJczZ4yDuZ/YQBt24oxe6Xg0iN9XoU5IEZ7bQe1FzMluY16BC3BQaaKuSGmvLHFI kIDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=HtJrPiyoWeU3Su29aTnmwX9+b3iRPUrA9oD4glSPKJQ=; b=eoDvT154Gjx2SJkik6B45LUPPjyb9qiBDaZ47TaUIkbJQSmQyVExSOHvZmUVt9P6qs WOLiBDeSANeSpiafSwpApj+fOTLnV0DCV7D1JEu8wu6yv7BMN4drQdjZLD0Q3eWmqiiU UeH1MKnJgcO6k1dRPxXrT6UwzvFu34zy0cKfPhPgYv+joJ56YCT3fyPgdcUTmRoiU5QD WtFjd5Vvg0H7dop9nQLQBRyxu9Yk/+p92vpsR/LiSOM6CkLD/NZMRXCYYGFr2WKSxfgJ jxXHg745Smf5mBEcfn5fIho1fRXky1qRZSbSDO5G1CGRu3c55i3Bf1ha35UhmUVOZKRG Pd7g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a11-v6si1906829plp.660.2018.02.21.10.47.25; Wed, 21 Feb 2018 10:47:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937189AbeBUNu3 (ORCPT + 99 others); Wed, 21 Feb 2018 08:50:29 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:40442 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936032AbeBUNFs (ORCPT ); Wed, 21 Feb 2018 08:05:48 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 8C0B011CC; Wed, 21 Feb 2018 13:05:47 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kirill Marinushkin , Takashi Iwai Subject: [PATCH 4.14 143/167] ALSA: usb-audio: Fix UAC2 get_ctl request with a RANGE attribute Date: Wed, 21 Feb 2018 13:49:14 +0100 Message-Id: <20180221124532.571939877@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180221124524.639039577@linuxfoundation.org> References: <20180221124524.639039577@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kirill Marinushkin commit 447cae58cecd69392b74a4a42cd0ab9cabd816af upstream. The layout of the UAC2 Control request and response varies depending on the request type. With the current implementation, only the Layout 2 Parameter Block (with the 2-byte sized RANGE attribute) is handled properly. For the Control requests with the 1-byte sized RANGE attribute (Bass Control, Mid Control, Tremble Control), the response is parsed incorrectly. This commit: * fixes the wLength field value in the request * fixes parsing the range values from the response Fixes: 23caaf19b11e ("ALSA: usb-mixer: Add support for Audio Class v2.0") Signed-off-by: Kirill Marinushkin Cc: Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/usb/mixer.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -347,17 +347,20 @@ static int get_ctl_value_v2(struct usb_m int validx, int *value_ret) { struct snd_usb_audio *chip = cval->head.mixer->chip; - unsigned char buf[4 + 3 * sizeof(__u32)]; /* enough space for one range */ + /* enough space for one range */ + unsigned char buf[sizeof(__u16) + 3 * sizeof(__u32)]; unsigned char *val; - int idx = 0, ret, size; + int idx = 0, ret, val_size, size; __u8 bRequest; + val_size = uac2_ctl_value_size(cval->val_type); + if (request == UAC_GET_CUR) { bRequest = UAC2_CS_CUR; - size = uac2_ctl_value_size(cval->val_type); + size = val_size; } else { bRequest = UAC2_CS_RANGE; - size = sizeof(buf); + size = sizeof(__u16) + 3 * val_size; } memset(buf, 0, sizeof(buf)); @@ -390,16 +393,17 @@ error: val = buf + sizeof(__u16); break; case UAC_GET_MAX: - val = buf + sizeof(__u16) * 2; + val = buf + sizeof(__u16) + val_size; break; case UAC_GET_RES: - val = buf + sizeof(__u16) * 3; + val = buf + sizeof(__u16) + val_size * 2; break; default: return -EINVAL; } - *value_ret = convert_signed_value(cval, snd_usb_combine_bytes(val, sizeof(__u16))); + *value_ret = convert_signed_value(cval, + snd_usb_combine_bytes(val, val_size)); return 0; }