Message ID | 1674631645-28888-1-git-send-email-quic_prashk@quicinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp146306wrn; Tue, 24 Jan 2023 23:37:26 -0800 (PST) X-Google-Smtp-Source: AK7set8aLlqxQt/hMly+kSS2dIfwYsOVOZd6xXzCQDcRhNd8stJS1TlvaDCOIqcBNie4albfRxfz X-Received: by 2002:a17:906:d143:b0:877:e539:8109 with SMTP id br3-20020a170906d14300b00877e5398109mr5591666ejb.23.1674632245839; Tue, 24 Jan 2023 23:37:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674632245; cv=none; d=google.com; s=arc-20160816; b=CIiIa9TcGacCkZXMtLrSWodjF9JGSSpyTQEF22lPwNSK6mDAl22Sf3Mes5grI9OGzV /yXeBMqG6NxXHefLdprmBtk96b3M1JZryTqBye43qo9dIVVc6I7fF1PzL/HqZkjGsvid i6OumeDaLRbMARB5b5SpkXwEvYHvmZLysGY+TYo/nJH4Vpenp3zoEJStssFeE987Kxeq PxT7GvGl0mSCloc4RQkOHnYKUgjo80ZoL665Usm9MCbdL2Xj7tX5vGhwz+r0UscSiNP6 etA76nRAihG98p289lon4fm5WXR2qa+oyjUNygMV6gSCMO3GkYtObF7Ztv+UpSrqv75b Q9oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=ULNqnRyw4epclnCKBllJ8Xlo23ISztCl3VRP+Fq8Ygs=; b=PjrG694pHfT4GDyByrhrjX4XNecUOjqyZ7bFnYhNaN08wnFvnOVKRXNtsIL4BJ2L+Z wvIlxVkZqb/c7YissStiguI1sdpMr2VGHnjwkJlzN+siB9/YNhQcWzEyNC/LCl/Gs9DR P0mLtEEc0T6zpJxTgq/drwLCFIS/K+VMqbgf83gtwQPgETP7n3ytndklGU7bkRzI2teu 7S1tnyAL6Awn786Yh4N3862GOxcUSo/wLgmDe5iXhYr4sdspLkwAzjf8zblkKsWbKtVI ghSN3yRp+rhF4PR5Hv/mvMzbrxKNJ/tcmQGZMQ5a8AuNHGKq+UjvxuHrWEDbz44JW2Vs 001Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=lLtUgJmQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fi23-20020a1709073ad700b0087122fab4c0si6889743ejc.155.2023.01.24.23.37.01; Tue, 24 Jan 2023 23:37:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=lLtUgJmQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234627AbjAYH1x (ORCPT <rfc822;rust.linux@gmail.com> + 99 others); Wed, 25 Jan 2023 02:27:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233619AbjAYH1u (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 25 Jan 2023 02:27:50 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23A8BEC64; Tue, 24 Jan 2023 23:27:49 -0800 (PST) Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30P7GAnw003812; Wed, 25 Jan 2023 07:27:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=qcppdkim1; bh=ULNqnRyw4epclnCKBllJ8Xlo23ISztCl3VRP+Fq8Ygs=; b=lLtUgJmQ+4/e8DP5Eroqu4h8rDF2mvE7e8rnQNUFTF39vhGDN9T+CXds+PEfZfSxk8/L BGQsGDO419b8WTaof20XdPHzVidEy+XMLJMxuCqKMzCAlWs60hm6PH9hYrCERh6jYwtg 7hWam/4zwvZPaqxXHBf0l5Fv5TpGbZOIvn6c5Segg21jAkHGZo38/EHvbDOOe1Bx8hss T48+uxTYcYLpLDQpnKOfwEmxByhP3eJZvFB2Imn60FXGbxG6RKQNJEprz/95CeHjc06O Q0lApgVoLr/4RE7htZiWfrNlxaImJJZBa0FNibKU1BFI1A1+FN3WE1LDjkSfQWg2bXxd Dg== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3najqa9a3h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Jan 2023 07:27:39 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 30P7RdM7009025 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Jan 2023 07:27:39 GMT Received: from hu-prashk-hyd.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Tue, 24 Jan 2023 23:27:35 -0800 From: Prashanth K <quic_prashk@quicinc.com> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Pavel Hofman <pavel.hofman@ivitera.com>, Joe Perches <joe@perches.com>, Julian Scheel <julian@jusst.de>, Colin Ian King <colin.i.king@gmail.com> CC: Pratham Pratap <quic_ppratap@quicinc.com>, Jack Pham <quic_jackp@quicinc.com>, <linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>, Prashanth K <quic_prashk@quicinc.com> Subject: [PATCH v3] usb: gadget: f_uac2: Fix incorrect increment of bNumEndpoints Date: Wed, 25 Jan 2023 12:57:25 +0530 Message-ID: <1674631645-28888-1-git-send-email-quic_prashk@quicinc.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: i3NvaGzwxVVNUW6bkEyuatvxGPoHvzPs X-Proofpoint-ORIG-GUID: i3NvaGzwxVVNUW6bkEyuatvxGPoHvzPs X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-25_04,2023-01-24_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 bulkscore=0 malwarescore=0 adultscore=0 spamscore=0 mlxscore=0 clxscore=1015 impostorscore=0 priorityscore=1501 mlxlogscore=730 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301250068 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755979182023267942?= X-GMAIL-MSGID: =?utf-8?q?1755979182023267942?= |
Series |
[v3] usb: gadget: f_uac2: Fix incorrect increment of bNumEndpoints
|
|
Commit Message
Prashanth K
Jan. 25, 2023, 7:27 a.m. UTC
From: Pratham Pratap <quic_ppratap@quicinc.com> Currently connect/disconnect of USB cable calls afunc_bind and eventually increments the bNumEndpoints. Performing multiple plugin/plugout will increment bNumEndpoints incorrectly, and on the next plug-in it leads to invalid configuration of descriptor and hence enumeration fails. Fix this by resetting the value of bNumEndpoints to 1 on every afunc_bind call. Fixes: 40c73b30546e ("usb: gadget: f_uac2: add adaptive sync support for capture") Signed-off-by: Pratham Pratap <quic_ppratap@quicinc.com> Signed-off-by: Prashanth K <quic_prashk@quicinc.com> --- v3: Added Fixes tag. drivers/usb/gadget/function/f_uac2.c | 1 + 1 file changed, 1 insertion(+)
Comments
On Wed, Jan 25, 2023 at 12:57:25PM +0530, Prashanth K wrote: > From: Pratham Pratap <quic_ppratap@quicinc.com> > > Currently connect/disconnect of USB cable calls afunc_bind and > eventually increments the bNumEndpoints. Performing multiple > plugin/plugout will increment bNumEndpoints incorrectly, and on > the next plug-in it leads to invalid configuration of descriptor > and hence enumeration fails. > > Fix this by resetting the value of bNumEndpoints to 1 on every > afunc_bind call. > > Fixes: 40c73b30546e ("usb: gadget: f_uac2: add adaptive sync support for capture") > Signed-off-by: Pratham Pratap <quic_ppratap@quicinc.com> > Signed-off-by: Prashanth K <quic_prashk@quicinc.com> > --- > v3: Added Fixes tag. Reviewed-by: John Keeping <john@metanate.com> Is there a similar problem for std_ac_if_desc.bNumEndpoints ? That looks like it should be zero when no controls are enabled. > drivers/usb/gadget/function/f_uac2.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c > index 08726e4..0219cd7 100644 > --- a/drivers/usb/gadget/function/f_uac2.c > +++ b/drivers/usb/gadget/function/f_uac2.c > @@ -1142,6 +1142,7 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn) > } > std_as_out_if0_desc.bInterfaceNumber = ret; > std_as_out_if1_desc.bInterfaceNumber = ret; > + std_as_out_if1_desc.bNumEndpoints = 1; > uac2->as_out_intf = ret; > uac2->as_out_alt = 0; > > -- > 2.7.4 >
diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c index 08726e4..0219cd7 100644 --- a/drivers/usb/gadget/function/f_uac2.c +++ b/drivers/usb/gadget/function/f_uac2.c @@ -1142,6 +1142,7 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn) } std_as_out_if0_desc.bInterfaceNumber = ret; std_as_out_if1_desc.bInterfaceNumber = ret; + std_as_out_if1_desc.bNumEndpoints = 1; uac2->as_out_intf = ret; uac2->as_out_alt = 0;