USB: dwc2: shut down the wakeup timer before removing the HCD

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@kernel.org
Signed-off-by: Yuming Hu <huyuming@kylinos.cn>
Link: https://patch.msgid.link/20261204082801.1382976-1-huyuming@kylinos.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 file changed