Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2904928iog; Mon, 27 Jun 2022 05:29:12 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vwCaaIArWhSDBZeli6gc3tHAerNBBb8FeTagCuErEx8IQd5vYHOaECyQnp13saDJkz/f1A X-Received: by 2002:a63:e243:0:b0:40d:391d:84f1 with SMTP id y3-20020a63e243000000b0040d391d84f1mr12624394pgj.433.1656332952158; Mon, 27 Jun 2022 05:29:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656332952; cv=none; d=google.com; s=arc-20160816; b=nTe8S0ARW5tjxqpVWTQizq+ZtB8uiSodNo0Ka9rAy73vlzcYYnGZma18HIxqr6YtFp KCyt3KCQe3tptzRua9F0tEfmDd7+kcwhMW5tAeTcae4BhdOJ29w4sOx3fTy+T1ulZxm1 xsBzQ+S+7FLXv9uHJcRpa/6r+bkTHrkOPc5ynqYErxURx0lK5U7Im2hJBsCw2dO9QH1m X9al41OB54K8k+lMQQ5STtF4Jz/AunUxpQ6rpGxVkoA8n0GP6fVx70qASDAsnG+F8xXv tNSco2rcjoYkay4xctCXwNhrFOanC3z3rIydcryQ/Q4KWvHIE4ZZyk1vIdQGVgFTZAJO hcOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dlpzHmsyD7G/LCgZPz7UoUsL+iYfomcympX7xSeBSls=; b=oaDNLaEuujut0NJg6DoRxKFF21aeqmLdYMXBPedVlcU9tt6ET7RqqpJveJWnAVFWZT POxeVj6UBzASr6+gbT5z5N6N5CBYZEcfcU8+pvqnAJhM8lBZBSqUfzD9l1T1EJMLDtXv l8w2titZI+hUPvWkZrhcbSG6pGrHf6IXFtOEMRN9I8qMRLZjPcfRWuc/FW+iYNFHeDPS IhJ3aUU4AMKjofAHo9Qf4a1wVTw57WIw9AQjNh4dysdEbATuCdljjA0F47Lu9vNtCpKC fYALk0CuQPjEMs4Pjx6fU7SQvb/po3mEBkAB+NQEyAH2F/hS8fKIvF68nlhs6zI/NRcA vTTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=W8UZWvvx; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r4-20020a17090a2e8400b001ecb26d5d20si13262542pjd.14.2022.06.27.05.29.00; Mon, 27 Jun 2022 05:29:12 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=W8UZWvvx; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235198AbiF0L1P (ORCPT + 99 others); Mon, 27 Jun 2022 07:27:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235070AbiF0L00 (ORCPT ); Mon, 27 Jun 2022 07:26:26 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBCC495AA; Mon, 27 Jun 2022 04:26:07 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3BE9A614A0; Mon, 27 Jun 2022 11:26:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A6B9C3411D; Mon, 27 Jun 2022 11:26:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656329166; bh=Zcfs2U8vP/9R8N+d/lYmQk1LfbiJ4kO8za9Vkp43rW8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W8UZWvvxPKDGPLfEJ/HICh9MuU2uSQO+GBQVcFSgdwrb98+1zCEop9VkO1w7j/fu7 Z9znGKB+ze7kxQt0/3WBjV6I/uFMQHfPzO1nh+MIkwdsMkuM6FxkzjaqF2NASxHJ1B BvoJQNM0zUfTBfS3wEWx1nglREY/LK30Pzd5uPjc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xu Yang Subject: [PATCH 5.10 071/102] usb: chipidea: udc: check request status before setting device address Date: Mon, 27 Jun 2022 13:21:22 +0200 Message-Id: <20220627111935.576659631@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627111933.455024953@linuxfoundation.org> References: <20220627111933.455024953@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org From: Xu Yang commit b24346a240b36cfc4df194d145463874985aa29b upstream. 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 Link: https://lore.kernel.org/r/20220623030242.41796-1-xu.yang_2@nxp.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/chipidea/udc.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -1034,6 +1034,9 @@ isr_setup_status_complete(struct usb_ep 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;