From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796354588; b=ugyGQTyQy9Kjjwbo/DiTkfqSg61z/kvnzsGJpzDnQk2WWB2C98tSDVsDQDPkutBcLiut CN9+wYDVY95D0cWtuBH3cWzkBFavFkXNz3cdsOCuTEaePyOP5Lyk8cLebULaHEKpfnzS3 qLHooQb6bRmLlDE2vYh7lGthbA0rwSCfGjdbrKjUJFcFSAuORYYypClF26exH339DZGrK GDzwNV03kIlobzsk4N3tNPgB3ZjXbvlgervu/lo4rwhD+7jDCEmBlTJSEXGTbjw1nMJ0O IN7lSgIqXjx49QKej3jYd7h561qUzOECLPSUcy7B3IiaWZ8wLJ7aGsaIAZQvpm4akwA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796354588; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=wNoKFY96Tkilewy1dncF5etjOL3XPQ+WkEWFhrkBoUo=; b=c6OmoteNI77xK0GJDB9FM7SviG0Y6GnZP+Oni8HPH4gXbkXZz0nFIN3w2aId2O/S220k 01xqqeGd7m15PxMAY8XeXZbeEMNHcLenTyV507kp+I4GRdX4n2DPHXMpsIILwIBmbbhJc 2Q2sOtdM5q2sGZabT9zzzDdEhSxV3Qm4eTUx2DEUCFTZZCukJgCz7Vt8mY0tbc8D6S2bF pwb7JinHE8VZdpQxXpbKRaW+ijXdVAMG1Rbk015vkQV1wj9pKMh0Q4MeAn6NuJX5HwuIS OG4Rz95CTQQnnYu9v3oRfxpv/QnaEsY6L6wKwiucodTrY32UU0/D3CAMiGTcoOycBnw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=K8ZOjYau; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2197606A322; Fri, 4 Dec 2026 03:23:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=K8ZOjYau Received: by smtp.kernel.org (Postfix) with ESMTPSA id F37F81F000C2; Fri, 4 Dec 2026 03:23:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796354588; bh=wNoKFY96Tkilewy1dncF5etjOL3XPQ+WkEWFhrkBoUo=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=K8ZOjYauorethxyibqbC8lRN4ElYiR6ALCqhmGCr14qDstI2Pc6M04KiI/FkE9TNd iycC8RGPX8dT96hmAreByrffEZs22Oj4jfBOJ5G64v80A8STy/zbUmGuS8y/Nlt9Qt HkHeG3zVVfeqrp3qkZpYa4Vcsj7KimFTWkK8FGPY= Date: Thu, 3 Dec 2026 18:47:52 +0100 From: Greg KH To: Yuming Hu Cc: hminas@synopsys.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Thinh.Nguyen@synopsys.com, stable@vger.kernel.org Subject: Re: [PATCH] USB: dwc2: shut down the wakeup timer before removing the HCD Message-ID: <2026120333-strategic-drowsily-1cef@gregkh> References: <20261124024516.2621743-1-huyuming@kylinos.cn> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261124024516.2621743-1-huyuming@kylinos.cn> On Tue, Nov 24, 2026 at 10:45:16AM +0800, Yuming Hu wrote: > The wakeup timer is armed from hardirq context (WKUPINT, 71 ms) and its > callback dwc2_wakeup_detected() ends up calling > usb_hcd_resume_root_hub(hsotg->priv) when the port is suspended. > > dwc2_hcd_remove() invokes usb_remove_hcd() and clears hsotg->priv before > it reaches dwc2_hcd_release(), where fd772af9512c ("USB: dwc2: shut down > wakeup timer before freeing HCD state") performs the > timer_shutdown_sync(). If the timer expires inside that window, or its > callback is in flight while hsotg->priv is being cleared, > dwc2_hcd_rem_wakeup() passes the NULL hcd to > usb_hcd_resume_root_hub(), which dereferences it without a NULL check > and oopses in softirq context. > > Shut the timer down before usb_remove_hcd(), so that an in-flight > callback always observes a valid hsotg->priv and any later rearm attempt > is ignored by the timer core. The timer_shutdown_sync() call in > dwc2_hcd_release() is idempotent and keeps covering the probe error > path. > > Fixes: 7359d482eb4d ("staging: HCD files for the DWC2 driver") > Cc: stable@vger.kernel.org > Signed-off-by: Yuming Hu > --- > drivers/usb/dwc2/hcd.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c > index 2e1927dfa..0d6549832 100644 > --- a/drivers/usb/dwc2/hcd.c > +++ b/drivers/usb/dwc2/hcd.c > @@ -5377,6 +5377,14 @@ void dwc2_hcd_remove(struct dwc2_hsotg *hsotg) > if (!IS_ERR_OR_NULL(hsotg->uphy)) > otg_set_host(hsotg->uphy->otg, NULL); > > + /* > + * Shut down the wakeup timer before the HCD is removed: its callback > + * reaches usb_hcd_resume_root_hub(hsotg->priv), which must never see > + * hsotg->priv == NULL. The call in dwc2_hcd_release() is idempotent > + * and still covers the probe error path. llms love to put huge comments where they are not needed, like here. Be sane please.