Received: by 10.223.185.116 with SMTP id b49csp4161226wrg; Mon, 26 Feb 2018 12:18:12 -0800 (PST) X-Google-Smtp-Source: AH8x22624wor8rN7vJoCjU5+LkCP5JT2rJrSStAF0yFqq9QsQ4dBs6RaU7v8/Xzo/E6hJZD/+fX4 X-Received: by 10.99.120.193 with SMTP id t184mr9575721pgc.348.1519676292096; Mon, 26 Feb 2018 12:18:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519676292; cv=none; d=google.com; s=arc-20160816; b=izIKJJM87hCZRejf2li6j28dn2FJyCNYARhrIKqnTFnhsKqV/jdczKmMqiBQcqzrlY 6JnZAwKMA0yvAeKAhcibvi45Rg3JHJDWdSz7GmvHMsBijjKiLATCTh3qwRirvzb1JkJE Hf837u7Pxhwn9IaN3+5PC1FnReesx+fqhUcM/NstWhSKkWXacZ8HYvwOp+qXVrG7Fmld uL8OKGYzlAhdWa5NPwO32XCzGhDzBYNWaaKN2fvD/zlFzqlez8D1xGGneb3hktkGW0v3 /d7sAkAkTQlkcosvSZ5Q5QxavgMc4SzGOxZSQdzKS1tYuq/vlgmC3kJKMzvy+3i4xtoL vbCA== 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=Wwsy1ZeEAxaIDOs/VAfzegrlZ4mIzI0OK7o4bdsqnzc=; b=uzTxf0Xee/jwmVxQ9b8CQzmvMZ4jrnabI5+l/LKH7MYaFQW7J5aYqm7ThqReu8cFGL eYm0WcncwpUimXez681l2A0mp+QHcfZFizXKcQc9DV/uFEx7Jh5F7w2Z0mJnMdnPb3Bl ssWHp6oV9Zk7IpGoJPemwO9KSaZGLD1/kXFiplLEgl+tj1T10jDgBW7DhK6K3CJsuUb2 wrxPdwwdl5qWGahqtHXm+TmhPz/X+aZWV9ZqIN6CkJ0tmMnOcpZs/pjBZRXKJ04HBhFz qblHXDftxaOBfWk67gQTBrupshRNTWDqWh/DXZfmpqMSfGue30bBDHIy0nKzen8mShX+ NwCA== 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 o5si2345607pfh.390.2018.02.26.12.17.54; Mon, 26 Feb 2018 12:18:12 -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 S1751713AbeBZUQG (ORCPT + 99 others); Mon, 26 Feb 2018 15:16:06 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:58628 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751669AbeBZUQD (ORCPT ); Mon, 26 Feb 2018 15:16:03 -0500 Received: from localhost (clnet-b04-243.ikbnet.co.at [83.175.124.243]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 2456710C9; Mon, 26 Feb 2018 20:15:57 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mayank Rana , Jack Pham , Felipe Balbi Subject: [PATCH 3.18 12/13] usb: gadget: f_fs: Process all descriptors during bind Date: Mon, 26 Feb 2018 21:15:40 +0100 Message-Id: <20180226201527.771288503@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180226201527.242286068@linuxfoundation.org> References: <20180226201527.242286068@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 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jack Pham commit 6cf439e0d37463e42784271179c8a308fd7493c6 upstream. During _ffs_func_bind(), the received descriptors are evaluated to prepare for binding with the gadget in order to allocate endpoints and optionally set up OS descriptors. However, the high- and super-speed descriptors are only parsed based on whether the gadget_is_dualspeed() and gadget_is_superspeed() calls are true, respectively. This is a problem in case a userspace program always provides all of the {full,high,super,OS} descriptors when configuring a function. Then, for example if a gadget device is not capable of SuperSpeed, the call to ffs_do_descs() for the SS descriptors is skipped, resulting in an incorrect offset calculation for the vla_ptr when moving on to the OS descriptors that follow. This causes ffs_do_os_descs() to fail as it is now looking at the SS descriptors' offset within the raw_descs buffer instead. _ffs_func_bind() should evaluate the descriptors unconditionally, so remove the checks for gadget speed. Fixes: f0175ab51993 ("usb: gadget: f_fs: OS descriptors support") Cc: stable@vger.kernel.org Co-Developed-by: Mayank Rana Signed-off-by: Mayank Rana Signed-off-by: Jack Pham Signed-off-by: Felipe Balbi Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/f_fs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -2727,10 +2727,8 @@ static int _ffs_func_bind(struct usb_con struct ffs_data *ffs = func->ffs; const int full = !!func->ffs->fs_descs_count; - const int high = gadget_is_dualspeed(func->gadget) && - func->ffs->hs_descs_count; - const int super = gadget_is_superspeed(func->gadget) && - func->ffs->ss_descs_count; + const int high = !!func->ffs->hs_descs_count; + const int super = !!func->ffs->ss_descs_count; int fs_len, hs_len, ss_len, ret, i;