[PATCH v2] usb: dwc3: qcom: check for hcd in dwc3_qcom_read_usb2_speed

From: Prashanth K

Date: Thu Oct 22 2026 - 00:48:03 EST


Currently dwc->xhci is not cleared if xhci_plat_probe() fails. During
system suspend, dwc3_qcom_read_usb2_speed() checks dwc->xhci and assumes
xhci is initialised. Since the probe failed, hcd will be null, and the
subsequent access results in a NULL pointer dereference

Unable to handle kernel NULL pointer dereference at
virtual address 0000000000000058

Call trace:
dwc3_qcom_pm_suspend
dpm_run_callback
device_suspend
dpm_suspend
dpm_suspend_start
suspend_devices_and_enter
pm_suspend

Explicitly check the hcd pointer in dwc3_qcom_read_usb2_speed
before accessing it.

Fixes: 6895ea55c385 ("usb: dwc3: qcom: Configure wakeup interrupts during suspend")
Signed-off-by: Prashanth K <prashanth.k@xxxxxxxxxxxxxxxx>
---
Changes in v2:
- Added null pointer check in dwc3-qcom.c instead of marking xhci as null in host.c
- Link to v1: https://lore.kernel.org/all/20261014105711.1708244-1-prashanth.k@xxxxxxxxxxxxxxxx

drivers/usb/dwc3/dwc3-qcom.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index ac68b4218b56..6ca51d37c35a 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -241,7 +241,8 @@ static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *qcom, i
hcd = platform_get_drvdata(dwc->xhci);

#ifdef CONFIG_USB
- udev = usb_hub_find_child(hcd->self.root_hub, port_index + 1);
+ if (hcd)
+ udev = usb_hub_find_child(hcd->self.root_hub, port_index + 1);
#else
udev = NULL;
#endif
--
2.34.1