Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2908235iog; Mon, 27 Jun 2022 05:33:03 -0700 (PDT) X-Google-Smtp-Source: AGRyM1twsB9ZSkdCv1MC+N6kkz6RWCrmnbpYGeQn06UUcDCd9RSVBCng/u09WrLYMYnOtkAiDwTr X-Received: by 2002:a17:907:9711:b0:726:443d:3724 with SMTP id jg17-20020a170907971100b00726443d3724mr11982017ejc.759.1656333182995; Mon, 27 Jun 2022 05:33:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656333182; cv=none; d=google.com; s=arc-20160816; b=eXfQGzx8HoQjY17FCoA6j7w1PZFPBmGe/5cu81xYU3KNqruNKAfuTzvy/nuDnVc0zK n8f7Gb/XGMsz93D95Vh0/WnMUFxCqiLITjh5zUfQDm8vw2qedcKP0EawSXwosxgZhpK7 86QRPL0jOYckIne0ckTGVovA2pxCdSQUn4vVpX72Q4lHZeAsxwar9ko0s/tythoh4cTX jPUPCdj8tkI5p5bfiFOy3Ad58PSA8R6yhTvz1iccdo0dgEujbgo010cyGIm/3jL6MJbH uwK/6p/o+9n4WcU/Y+fyYJQrCrLpFZxOqt8DwaxXbdNjt0mD9pDG5KLomv28uQJB6VUi LUmA== 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=OOyd5Qbi/jpooKMIBGqoH6CVN+mMSNVl3HxgKRiFDbc=; b=FSpUc712u2xrD+yvI+GcybIYziyrDVw8UvFB+7eQndRBZ+u0cAym3J/gT8VoVKRb3J YY/YmAgyN60p/TdUsGPOkmyEGvrgzDH1OYwX4MRRH+PAfVBiRTZWKgobq/+17mApjtds CQCCvquAwpZ4U5nI5VMHIMaPAEZWBEqCH77Of74WQr+FLJ7rfGNwh+PgHyOvC62P8YQj baMB+5WJxee8ukkydMn6Q937/BSu1T4AcnLmjJZTudn2exIbtuN5mBdJzs5PtlgOPFdj dWRuRdvgvcBIgdveVk/B5aGMgsa9mQpXVAYnmGQUvKCPa/ExgCBotxqmY57f4YOKt8oT r88w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aNzyfZv9; 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 hr20-20020a1709073f9400b00726a5db994bsi3559935ejc.477.2022.06.27.05.32.36; Mon, 27 Jun 2022 05:33:02 -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=aNzyfZv9; 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 S235720AbiF0LeI (ORCPT + 99 others); Mon, 27 Jun 2022 07:34:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235765AbiF0Lck (ORCPT ); Mon, 27 Jun 2022 07:32:40 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 874CAB873; Mon, 27 Jun 2022 04:29:39 -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 ams.source.kernel.org (Postfix) with ESMTPS id D79F3B81120; Mon, 27 Jun 2022 11:29:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2804BC3411D; Mon, 27 Jun 2022 11:29:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656329376; bh=H1bSBWVGZV+5s+ZnLeAHu/3Oh13Lb4XGnzywVcrTRGk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aNzyfZv9ODNMCb1lAvpc3MXcS5sFoAjom13ZIMIWtwM8yvWpztzlO5v8f4SLvIVxx 6UE4NyJZ4y6nYtjsBEosF7VgOCGXWDFjF7XyjuEj2mnbu5cgQnnnE313Gcd7ZTIgMU 7mr2GLAeLSIcvM0LdZmzawVH4fxmdN/pCx17x/cU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xu Yang Subject: [PATCH 5.4 37/60] usb: chipidea: udc: check request status before setting device address Date: Mon, 27 Jun 2022 13:21:48 +0200 Message-Id: <20220627111928.781890501@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627111927.641837068@linuxfoundation.org> References: <20220627111927.641837068@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 @@ -921,6 +921,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;