From patchwork Wed Jun 28 22:24:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 697656 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 C987BEB64D7 for ; Wed, 28 Jun 2023 22:25:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231332AbjF1WY7 (ORCPT ); Wed, 28 Jun 2023 18:24:59 -0400 Received: from mail-db5eur02on2071.outbound.protection.outlook.com ([40.107.249.71]:3265 "EHLO EUR02-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231300AbjF1WY6 (ORCPT ); Wed, 28 Jun 2023 18:24:58 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XpwnuLpMD0v3APyu5jzeBFW4z9wFlw1HXLusPrtL+u34Omhi3J7EF6cZISBmMVTt9yF/pFTDe8Q7N4ksIrgZhxo7H+Lb3p+tBseYCY4ChRDB+3jVrUkf3TDiNZQRBXFR/zyzttt6q4F/RbbWyHUG4ok4CdEdPEg5B4x0x8IO7opaLOIUeBm5JiElojw1ihQfHeknJhzqYQmPGePKqiC5Jf3twNjlucVTqE6toYC4B69Q/jfhFChe91WzX3MwoMuxr1O0+WlTor7XuFcfvjBABoRfBSo23O+o2Ad04HxfKQfbMwPUf9mVRdR7Uf4AkLVGXrlwjoyFXJkGIrvV6CIslg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=k9MJqgXQBKH9p6GXj7nxHl/BRBNIsFl4yA15DxmnC7Q=; b=Eah04OFZXS7t+7SzgSyi/WNkELY/dKWywVJ8ryNQSSIth8+qtOqTsj4UHeB+W1O5maHiiP2TjjMDZV/XpeGH7IyXPeUf7ZzYz+KtMol6iG+Bj6aObvFh2HLVEv3Oe5WBg/M3M69g88wmfX4ssraj9Q3j3AMN9LX5eibDGc5tXN9rqcHcq8gbr30fnt0xMRHspaUi00tZ6NXXasDLxhdrMuvVcUNVmcjLEOFibcGbedb45a7ugHKYe/f+sJJvhdWb4Lp0cRnqOKGWNvJu3FKK9WP4oP4l4UO2DEQgKbfE4Qf647OTFcgHflRAO0IOl71L4mjo6fzhPSHBLimlYUrHHQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=k9MJqgXQBKH9p6GXj7nxHl/BRBNIsFl4yA15DxmnC7Q=; b=EpYEd/azGYEoOeOAT4yp3nB62n6XaiX44eAh3Q5j5cH3tTpPhXMUUsEb37lk1H0byptjb3D83Y5Ng+yg4bKLdAHo/QIpNxiwMCqKGS3a+U4KQXiBxCS8IUBLghCxmqn2rhDo/rvPV9wLiQrP33rBwDj6nLrjZbOYrJxcRdgetb0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) by VI1PR04MB9978.eurprd04.prod.outlook.com (2603:10a6:800:1d7::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Wed, 28 Jun 2023 22:24:54 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::4a2a:262e:415f:e41c]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::4a2a:262e:415f:e41c%7]) with mapi id 15.20.6521.026; Wed, 28 Jun 2023 22:24:54 +0000 From: Frank Li To: rogerq@kernel.org, r-gunasekaran@ti.com, imx@lists.linux.dev, jun.li@nxp.com, Greg Kroah-Hartman , Elson Roy Serrao , Thinh Nguyen , Andy Shevchenko , =?utf-8?b?SsOzIMOBZ2ls?= =?utf-8?b?YSBCaXRzY2g=?= , Prashanth K , Peter Chen , linux-usb@vger.kernel.org (open list:USB SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 1/1] usb: gadget: call usb_gadget_check_config() to verify UDC capability Date: Wed, 28 Jun 2023 18:24:36 -0400 Message-Id: <20230628222437.3188441-1-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SJ0PR13CA0036.namprd13.prod.outlook.com (2603:10b6:a03:2c2::11) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|VI1PR04MB9978:EE_ X-MS-Office365-Filtering-Correlation-Id: 86813297-e0c0-4536-4c10-08db78267ee9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: H0XUWOr+MXgUFfX0TvTs5FsOl3TUVevWSTFef5zZPsjL5fZZwruDitAA8iI3BOvbCVu1+sNHigCxtzmZyFGt+iB5bo/ltzWg0kw2snEeJOqhqZoHtbPX9OhJEsp0m+BtZpWK3pUMFUiPTTMP0JlqIDVGWkK7IirV/wrfLjVARgCYSiUjeLfUNL0mei0liELxNXob7MvIV0mwDE+X4tr/SLS9JQW4+FemQdvMRoN8G/K0+qg5iAxaQ+lvMbuDbc70R/SpHLIbPvhom3eij62HxWIKodLGG5oQlZFmSxAGI1S+4rtQ9IQxNNW+058b9SdMkbtqavF3c6132UnPGqJjjWoblVjws+TzHQkVPeE2au8F6dRA0azSuufPwyt/0HyeBKVHZVdkdabBb7R7juEJCWZLqT+K/x+EUwfKYnuh112J7OOkus2EEP5A6RA9wG5ajTZSUSLnErQ0xZ4izChknVOwbsBV73Q9VsK1gDnWyL6OgwBaTN/w06OqrCog7O3dpod/viq3PszIB0V4eJ5AxfHp1TV+DnOyCXDlisazjdNo974GNNFAt3oMsU8q4vqOWF3CmRDrK34jtHq1K8H7NdjHxsH0VYW5TmP7lRSQ6b3iypmbopRWsc8RRCyrfuYgSC3BASzqUctZhbNL9lo6RA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB4838.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(346002)(376002)(136003)(39860400002)(366004)(396003)(451199021)(6512007)(26005)(2906002)(86362001)(6666004)(6486002)(52116002)(38100700002)(38350700002)(2616005)(921005)(186003)(110136005)(41300700001)(478600001)(36756003)(66946007)(66556008)(316002)(66476007)(1076003)(7416002)(6506007)(5660300002)(8936002)(8676002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CjRP3YKvVtgHap+HKFnHf54MYC8YXKstCa8na02Kvl/g7OhiqKtgMhUawCUN1OtXG1yjNnvZfHt5IpM+C4hLH5XxotAkeNpWEHsU09zFB7ybMFjVvOctGfXsyoCkgIVjG5UIXuDg/7Y0s0MoWeJD+yAxhYD5k4Lq+NQ0+fEOkW3pjC5C0J2UNZ6Gz+gCK1nrW4wibXMrgfXD2QUD+nqPU4UgjROqxQd2/GBWTYZ+tzDhcYHx1A0RDVx+bUlmLi1e+6wgTABSk1EgHT9uX663nHIeBzgrSPoRLfqKBA8xaVY1Rby6akJ/29tTbSPf2B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pY53MddifJIXun7Jwom2E8I1WtKfu9QTNj8YVW7z5Z2ln8enbYwlw3GsFFRzgFWzJ+U43X5ZPURlsR+PQf1vgvvK31oUqTVZHJkN7yg4ZUKUi+i33VZABIznovo2oXa53nHUH6ZKgmRAFdJsQQGWFXsgyM5nSKObzWfc6QEhLYVUsO/56Vurp2of9sCSIqZO/H/KcEQMJ X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 86813297-e0c0-4536-4c10-08db78267ee9 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jun 2023 22:24:53.9665 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wFZY3ZKtdaU2SuRmQSalrtmXFH5AqBaHJBUbS3BW65AtuecJfTmP0ghNXsWtdu7K7TdxxLQDIQ+YB/yRuB99LQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB9978 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The legacy gadget driver omitted calling usb_gadget_check_config() to ensure that the USB device controller (UDC) has adequate resources, including sufficient endpoint numbers and types, to support the given configuration. Previously, usb_add_config() was solely invoked by the legacy gadget driver. Adds the necessary usb_gadget_check_config() after the bind() operation to fix the issue. Fixes: dce49449e04f ("usb: cdns3: allocate TX FIFO size according to composite EP number") Reported-by: Ravi Gunasekaran Signed-off-by: Frank Li --- drivers/usb/gadget/composite.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 1b3489149e5e..dd9b90481b4c 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -1125,6 +1125,10 @@ int usb_add_config(struct usb_composite_dev *cdev, goto done; status = bind(config); + + if (status == 0) + status = usb_gadget_check_config(cdev->gadget); + if (status < 0) { while (!list_empty(&config->functions)) { struct usb_function *f;