Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2928090iog; Mon, 27 Jun 2022 05:58:53 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u/el2Jr3Vk35QarLH5e1AO5cgroJly1I506pE1sGD65N5uY3n9mfsF34UtXGQIBANekXvd X-Received: by 2002:a17:902:f804:b0:16a:da1:1ef7 with SMTP id ix4-20020a170902f80400b0016a0da11ef7mr14441314plb.17.1656334733436; Mon, 27 Jun 2022 05:58:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656334733; cv=none; d=google.com; s=arc-20160816; b=vzwSfmMCSWT/7trNSzuC2OML29l64B7MUmyfhI+xasfJ+b4iMcs4EEHae0+i+vw42Q iFfcxkhlKKQ6GPbth9X2bnEIeXy2MA0R9GCzuJ3PqzOrlAODTtcjfTnejxbuE6ohHKT8 aK29wNjgHNq3CdGDaeWp8/jIUaZ09WXGCUzA4Y00zZG1nsjb9urTfhroFNC/1V2fpxS3 chI+y6wkAqQZDO9brdR4dKeqchtO35lVFRzEv1asHeW0D+NGS5qhUzbZLYX2wFnPBHzS 1YGxISLyIkrr2RbfeybWKlyEm2YVaHa381JX9r9fCU1CxChRbC/PJwXQ4q7ruDvVt4qe aqjg== 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=ItvPoq93ARNyTqRsO7FEoC+NFIujsuoAvFjjN08Hg+g=; b=dltlm8rh6nWe03EYSAK14MxOrU4X0WJBI3N2M3X9Ec/YpjcdV79kUAYkB0J3OOK6V2 1Lf0qz2eHiIHpHFQr7ffRoU36glcP4J8EWiG+yfKXwYPMjALFeQlUg/ef7ozRel3baGC OlXduRv9Cwq/wdX5QvKaNTjVCD4frYU9l/46vd5iCOqcFiowHZItB4V9Ik3HCUA5Eaco It3ogqngwjrl1NXZYA7LUZ6Xi8YUE+8PkakMHeWpItjorEV7gnu3Zz9qgT5PjYaEzsCP +y8nd1b+ZjQWPCtTBkRyliIGjInZivR0MhPktmhpagDJ1zx5o6F9thjE4tZUXFmdAgfx VV6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=K6Rohf26; 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 l2-20020a17090a150200b001dcdccd55c4si18013036pja.100.2022.06.27.05.58.41; Mon, 27 Jun 2022 05:58:53 -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=K6Rohf26; 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 S239374AbiF0L5M (ORCPT + 99 others); Mon, 27 Jun 2022 07:57:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238167AbiF0Lu2 (ORCPT ); Mon, 27 Jun 2022 07:50:28 -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 2ADEE1106; Mon, 27 Jun 2022 04:43:36 -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 BDC1061241; Mon, 27 Jun 2022 11:43:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B719AC3411D; Mon, 27 Jun 2022 11:43:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656330215; bh=MI0bsniUwDkWSt13JruOm4ZUqJHUFJtapMTmtz/L4J8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K6Rohf26nWFU1gudn4ypUpNukFl7nHzF4fwN06yeWdOf0IUN/FY19xf8X8IMFxtCQ +xBbV71PJYqi5suNE4Nda3uC675qfXHzOECvVVqatqIxvO19ouKBPlo8D0uGHuF4kP Mh3U/0TrSytWKV21yX8eRWFQmiFfpRgWtcCXB/RY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xu Yang Subject: [PATCH 5.18 121/181] usb: chipidea: udc: check request status before setting device address Date: Mon, 27 Jun 2022 13:21:34 +0200 Message-Id: <20220627111948.203330169@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627111944.553492442@linuxfoundation.org> References: <20220627111944.553492442@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 @@ -1048,6 +1048,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;