From patchwork Thu Jun 23 03:02:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 585108 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 66364CCA48C for ; Thu, 23 Jun 2022 04:41:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230226AbiFWEli (ORCPT ); Thu, 23 Jun 2022 00:41:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231951AbiFWDHT (ORCPT ); Wed, 22 Jun 2022 23:07:19 -0400 Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20056.outbound.protection.outlook.com [40.107.2.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E496443E5 for ; Wed, 22 Jun 2022 20:07:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hz7q0vkA+Q2DCc3g9l7uH8ocG+yIVAFX+j1zKsDytCIa5AFIReUvE5Fgfd8FIs0d0MOim7T8lveuSKFjqAOqv6dQs/GjWraGJGudw99x97A/NIrPKNpUXhpPHuuSVAQfBQqdm77a/P9AW8vIO3e6IVuCCs+LX+t0FsQYnRlDtffULh3uPVCMq9TiwwFXuaykqO7AOODFfg1ZyeBKoESGgA3A1vuNWfyqXRP6G4ZBdko1P63/LaXcm4mRNdxokAGif+nMQSU4/tLmodq+WmmAT2KXagOUHSFttO3SdAH5apteBJp0VNr+xK1HSs+4m7fFx+VnsFynMHqYIeBYgjnc8Q== 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=ivQybAig8niBvd78NY1XcYpOt7uPBlcP/XNWODsS1mE=; b=YBvt/UiS0ZEYSmY7j82WOT7/Z67m7TOl8j+adNRJ4XsQrLBjqM0j+zD19xxg+t32Cj8bzuoBY8sxuGj3TaWH8d1zDICJS1boFpqVpKGXQkLggz0VKeuyoafDmU11bCm0rVwfG9YukQOR6oAAi/wZ2HSW6H+DVy8EtiGvFtPjMFBkniHEmrjyBKED9hejh+ZTQA5F213Z2YK8dRTSVQy/2Wr6lAtD6iCGRqNtzgm/P2fW3RlSkM3QZgI1U6StHECjqnUcKhrb5toJ5pERViZbJcPyqF+KtlnbBPd/3Ehl0yaAjh6RkcduzjN50w8Iea4BS5i8PoFdZ0ft2J2/DSQXnA== 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=ivQybAig8niBvd78NY1XcYpOt7uPBlcP/XNWODsS1mE=; b=GtKfoZquFZvN7G+IiYsq2SCS6bMBmhNkbSGayPzA73MAeQKM1HHy5Zerinag1riTuKEkuKB1k8yBEMx1OR/BpwuMzril3wf6zdNv3Bw/cPDDdXWuMlhBRIJ5r4M6HQeR4JB4oNoqz+R4o1bFNSgk8YZnJeV9igAeEWHwEZvkX/I= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8784.eurprd04.prod.outlook.com (2603:10a6:102:20f::23) by AM0PR0402MB3523.eurprd04.prod.outlook.com (2603:10a6:208:1b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.15; Thu, 23 Jun 2022 03:07:15 +0000 Received: from PAXPR04MB8784.eurprd04.prod.outlook.com ([fe80::b1cc:4d23:3361:127d]) by PAXPR04MB8784.eurprd04.prod.outlook.com ([fe80::b1cc:4d23:3361:127d%9]) with mapi id 15.20.5373.015; Thu, 23 Jun 2022 03:07:14 +0000 From: Xu Yang To: peter.chen@kernel.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, jun.li@nxp.com, linux-imx@nxp.com Subject: [PATCH] usb: chipidea: udc: check request status before setting device address Date: Thu, 23 Jun 2022 11:02:42 +0800 Message-Id: <20220623030242.41796-1-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.25.1 X-ClientProxiedBy: AM0PR10CA0097.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:e6::14) To PAXPR04MB8784.eurprd04.prod.outlook.com (2603:10a6:102:20f::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 68eaa275-270b-49bd-a637-08da54c5792e X-MS-TrafficTypeDiagnostic: AM0PR0402MB3523:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 44zR85Cg/2PS8kR/o9iqfb3SQ3twlAaPVARj29qJEjN1XYJ3BtJnVrtHnnqHGwnIK9iwABygIAx7xEUi7smpanr8zX+U0AjImOCd8+68K2uIt2EedO1lpeNwZc9lm64mNSLoTJ5n9EO5DQ9qVKoa8bNr+LtSxywm3jjgr3QHpY9V1r8owhUVR3Fz2zQs9duG2t155lgwIFDl+4KXZ4wPrzkJuh+e0rp72GZb7yhEG4hv0oodrJZmWC2SFpwSg/WUo9nKn6E1Er+HJKkAn2I6DEJBn+3Zl1Mb3NwPYPraDPXdkIAe/ux2FApj0bKckFkkCnEB83QfwaRndMgR32p8jsdEreRZUAmwkU1xBkpG3nGHjcvdNXBSjrvMb2sK2LmZ/hAhLrIRy74J7q/JM6YtXC6mbnN31fJ8jwmM7zpOaE61mcYPLZ7+lXv9ANYrWBxM+igum0gAElBx5nCe6MNVdfYdjsheDu0mEAPSmJf9njw2MvWWLvAObT7VImhkNky6eZxGKVXTZgD4LI4GZWEh42LKICZCAmStzf2tU4JcfbiToE3S7J/Ym2pZjsxHmy38n+IJGPRAr7TV0qLOz5hELaRCj0apxKtPEdo0cAUITsSJcg2rdwiC3LRpJ6Xa9qX3hmntm6WJF4SxjSqyc6axnfe7ep0m4ItB3BurJUTSeYwAmeH6QZM4eSnEY0O2fMp5arvL4A44fjHu+auXbRACPqgwKjYKHyWX7HMRfI1Ml9pEA2wpekTin6mve1WkHQhF X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB8784.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(366004)(396003)(136003)(346002)(376002)(39860400002)(6486002)(38350700002)(66946007)(38100700002)(8936002)(66556008)(8676002)(6506007)(2616005)(66476007)(5660300002)(478600001)(4744005)(1076003)(186003)(2906002)(83380400001)(4326008)(36756003)(6666004)(6916009)(6512007)(52116002)(86362001)(316002)(41300700001)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EmToC4QlpTQKbfu5AEVU4YKFRxEnXgePI0gPLgNhTtQeWZULxFcOBxHGw5xTR4vr8iVXFvPEMbrVYYirrHavMNBse5y/1yYC+1zZAqgCgXxVQ4dHjHOiNRnk+90be2VU1O6Ikj3gG1bakpa1wPT5Yc5Wba5mq/jEro6VVjs4uWZ8/CfHeHrtfs+O0CUqorsD+JToeKNy0gtIGeqWDxG5+sXKw6DaRpONfv0TzpeIRQ2ONXeAWYk0MQ0df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MBpUBMU5cp7eSfVWYzjd4xBlSCwH5bmdbVB7x1kreIqSgaRtiYlgmY/EA6Q8xfzvdWQX5JX0sC2W1uPyxpSObnoSuhUzVGEggItVzT04OUnNeq2k/aWsu7eBtDa1Tj2LFZmHibjKzjjMlaW61vVWVYW6CAkvQ97sVIQdxrQpUWYZMEo6vphn7onyubxGdfaOsfqzSsrprSPaZBxg9x8XNhZCCmcUhLRjOssfgThBbB0Plype7h1q6AeA3cSRq4bybwpSD1CMxPBAoPekKMUIw3rTMJLTZ3hzYfwsbeGnpgJ73x8sRtE+3hT10Auw4CLMoksHsseGqZboExMswS3kaELSuIdI10MfadZ7aAGkBtk3tIUjjuIjb5nHl60n7c3HnlPI9Wzg0274n4u7NpJeBitNQKPtUw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 68eaa275-270b-49bd-a637-08da54c5792e X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8784.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jun 2022 03:07:14.8499 (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: dMFPEc9RQyvw/aspxxSFd7ObYa4MSKPsC5HkwdbtuWbSXElUpF2SDBq2gKXmrVHX7PDkOxotQ9wCpXBuR1tnEQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3523 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The complete() function may be called even though request is not completed. In this case, it's necessary to check request status so as not to set device address wrongly. Fixes: 10775eb17bee ("usb: chipidea: udc: update gadget states according to ch9") cc: Signed-off-by: Xu Yang --- drivers/usb/chipidea/udc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 0c9ae9768a67..8c3e3a635ac2 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -1048,6 +1048,9 @@ isr_setup_status_complete(struct usb_ep *ep, struct usb_request *req) struct ci_hdrc *ci = req->context; unsigned long flags; + if (req->status < 0) + return; + if (ci->setaddr) { hw_usb_set_address(ci, ci->address); ci->setaddr = false;