From patchwork Wed Nov 23 08:48:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashanth K X-Patchwork-Id: 13053255 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37CBBC433FE for ; Wed, 23 Nov 2022 08:48:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236420AbiKWIsq (ORCPT ); Wed, 23 Nov 2022 03:48:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236660AbiKWIs2 (ORCPT ); Wed, 23 Nov 2022 03:48:28 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D69D553ECD; Wed, 23 Nov 2022 00:48:26 -0800 (PST) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AN8RrlV014933; Wed, 23 Nov 2022 08:48:18 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=Pi8BiOP1Ato5hfmyoHvMzNY2xZfCye5vh2+Bl//5nhc=; b=IK0ozcvPXdp9i3aYvdmFG62tXAY28ts0oYNeGGroD8Rw5EIbQOaeHiFxdd8C9ACa1Eoy QLrkzpB2YjzXywhVV+QtmtLyVpRXyJabpC9kxX5xAvY6I1gLJjFfNnTBhv9tizuDf52/ 5n1l8QqeM34YOecluHOHLiuB1YdBM15jMZejnZ4fEHygQ2J+RyDK8SgnFcLtWCzylljC 8jbJ6NAZQfn+ykHp0LdpIzhxd2k3jiSXl4oiTHBINaysyt2rikDsVRK4F34Dubnp2M+E NVUVTepiqzjUAktBHwU7eXIin1r8fGcLhVQlN5iGaWa34W3JEBXQk3fqnc0/PHht7g3x LA== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3m0twqawdr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 08:48:18 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2AN8mHZt003930 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 08:48:17 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; Wed, 23 Nov 2022 00:48:14 -0800 From: Prashanth K To: Greg Kroah-Hartman , Pavel Hofman , Joe Perches , Julian Scheel , Colin Ian King CC: Pratham Pratap , , , Prashanth K Subject: usb: gadget: f_uac2: Fix incorrect increment of bNumEndpoints Date: Wed, 23 Nov 2022 14:18:10 +0530 Message-ID: <1669193290-24263-1-git-send-email-quic_prashk@quicinc.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) 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: 3PaFAXxbfqutTscV2xO-9y3rMBOCIfIR X-Proofpoint-ORIG-GUID: 3PaFAXxbfqutTscV2xO-9y3rMBOCIfIR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-23_04,2022-11-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 lowpriorityscore=0 mlxlogscore=637 spamscore=0 impostorscore=0 adultscore=0 mlxscore=0 malwarescore=0 suspectscore=0 bulkscore=0 phishscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211230066 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Currently connect/disconnect of USB cable calls afunc_bind and eventually increments the bNumEndpoints. And performing multiple plugin/plugout will incorrectly increment bNumEndpoints on the next plug-in leading to invalid configuration of descriptor and hence enumeration failure. Fix this by resetting the value of bNumEndpoints to 1 on every afunc_bind call. Signed-off-by: Pratham Pratap Signed-off-by: Prashanth K --- 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;