Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2435208iof; Wed, 8 Jun 2022 05:04:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywmdjGafWOIlvvikrIQtHtp3c4cGbmtIZ67iMB9axtn3gRDF8hoP/ZrqjoXyrOC1/VyFmP X-Received: by 2002:a17:902:7202:b0:167:6548:3f3e with SMTP id ba2-20020a170902720200b0016765483f3emr21165930plb.98.1654689846426; Wed, 08 Jun 2022 05:04:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654689846; cv=none; d=google.com; s=arc-20160816; b=AQpv0dBF/6IEugssWybae4R79ec6mxDKhrSrn4DOCv5ficSe5ph4gpJ00gh8g4zVvk B/K60dt5ke+HCA8Chy7AwWxYQZ0HxSbcPNndlzWAYq/6qXf//AmF/jtrslAcyz+uxrQZ JpZIody9YdOhbc5b1BncETelAR0v5yL6VRWVORnSJJ++OhelHtJCmDglbTO1vB3wGuc9 +2s3zPmmFUk4qtezTnMwhVTy3xV0v16kDAlp5/kJXXIWvGFB4YPPTKzmvoRaxsS6CSH+ eaCpoOcl1pslPpDRIu9PaXds7KqZ/9FV8ReiceMVFN4Q8hDLx4bB0LOCZycI1VeC8ZD2 VmyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=d9YuL23scSV9phJdUhyURkjs0P/02/WF9qhZefsr2fc=; b=D8oN564exkU71AbpQ9kYteZpDZ16zEfC3v4uH8HzTK6FXV7dt5h8Y3+PFiQWzsR4zY 3EglgpBftLhEVRI19fA6+b35ZRQ4mnVNwb93gvIg4tN2IafFeLgbS/qcNPXc9AUabz4k pjJYSW+4ozUu5YDPpF1PRWET3OeqrgWR08tM2bqwoM6agJV8h4qZlQ2x0RYae31KHCN8 MNIMm0SUoyjDxJCc7PWMhgVzmtcofTKePfK+wbgYm7VdqSOPRO73zFG9/aE7VohIJYxO JD/wbCIrZQag2GwjQqyxOHIF1GtXWxdazvS1ToQmmdRw+1N3QUHQQauBAsfkcEkSe5Jy bqZA== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id x14-20020a634a0e000000b003fda62fb969si12797983pga.590.2022.06.08.05.04.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 05:04:06 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 64CB41B9F8E; Wed, 8 Jun 2022 04:34:13 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238132AbiFHLeC (ORCPT + 99 others); Wed, 8 Jun 2022 07:34:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238098AbiFHLeA (ORCPT ); Wed, 8 Jun 2022 07:34:00 -0400 Received: from jabberwock.ucw.cz (jabberwock.ucw.cz [46.255.230.98]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9685B117656; Wed, 8 Jun 2022 04:33:56 -0700 (PDT) Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 93C821C0BB4; Wed, 8 Jun 2022 13:33:54 +0200 (CEST) Date: Wed, 8 Jun 2022 13:33:54 +0200 From: Pavel Machek To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, stable , Albert Wang Subject: Re: [PATCH 5.10 011/452] usb: dwc3: gadget: Move null pinter check to proper place Message-ID: <20220608113354.GA9333@duo.ucw.cz> References: <20220607164908.521895282@linuxfoundation.org> <20220607164908.873134406@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="jRHKVT23PllUwdXP" Content-Disposition: inline In-Reply-To: <20220607164908.873134406@linuxfoundation.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 --jRHKVT23PllUwdXP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > commit 3c5880745b4439ac64eccdb040e37fc1cc4c5406 upstream. >=20 > When dwc3_gadget_ep_cleanup_completed_requests() called to > dwc3_gadget_giveback() where the dwc3 lock is released, other thread is > able to execute. In this situation, usb_ep_disable() gets the chance to > clear endpoint descriptor pointer which leds to the null pointer > dereference problem. So needs to move the null pointer check to a proper > place. Ok, but could someone check the error handling there? There's some cleanup at the out label, but moved code does not jump there. Best regards, Pavel > +++ b/drivers/usb/dwc3/gadget.c > @@ -2960,14 +2960,14 @@ static bool dwc3_gadget_endpoint_trbs_co > struct dwc3 *dwc =3D dep->dwc; > bool no_started_trb =3D true; > =20 > - if (!dep->endpoint.desc) > - return no_started_trb; > - > dwc3_gadget_ep_cleanup_completed_requests(dep, event, status); > =20 > if (dep->flags & DWC3_EP_END_TRANSFER_PENDING) > goto out; > =20 > + if (!dep->endpoint.desc) > + return no_started_trb; > + > if (usb_endpoint_xfer_isoc(dep->endpoint.desc) && > list_empty(&dep->started_list) && > (list_empty(&dep->pending_list) || status =3D=3D -EXDEV)) >=20 --=20 DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany --jRHKVT23PllUwdXP Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRPfPO7r0eAhk010v0w5/Bqldv68gUCYqCJIgAKCRAw5/Bqldv6 8uR1AJ0YQhw3nc4YH/yLBp6Q9/VM9rlTBwCfWEChQvJhSJ0kBB3UYR+O5TMNdUE= =mj4B -----END PGP SIGNATURE----- --jRHKVT23PllUwdXP--