All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] usb: dwc3: qcom: check for hcd in dwc3_qcom_read_usb2_speed
@ 2026-10-22  5:26 Prashanth K
  2026-10-22  5:33 ` sashiko-bot
  2026-10-22  7:37 ` Peter Chen
  0 siblings, 2 replies; 3+ messages in thread
From: Prashanth K @ 2026-10-22  5:26 UTC (permalink / raw)
  To: Thinh Nguyen, Greg Kroah-Hartman
  Cc: linux-usb, linux-kernel, Krishna Kurapati, Prashanth K

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@oss.qualcomm.com>
---
Changes in v3: 
 - Initialised udev to null, as suggested by sashiko bot.
 - Link to v2: https://lore.kernel.org/all/20261022044748.2303528-1-prashanth.k@oss.qualcomm.com/ 

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@oss.qualcomm.com

 drivers/usb/dwc3/dwc3-qcom.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index ac68b4218b56..e4bf0d5fc9f1 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -231,7 +231,7 @@ static bool dwc3_qcom_is_host(struct dwc3_qcom *qcom)
 
 static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *qcom, int port_index)
 {
-	struct usb_device *udev;
+	struct usb_device *udev = NULL;
 	struct usb_hcd __maybe_unused *hcd;
 	struct dwc3 *dwc = &qcom->dwc;
 
@@ -241,9 +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);
-#else
-	udev = NULL;
+	if (hcd)
+		udev = usb_hub_find_child(hcd->self.root_hub, port_index + 1);
 #endif
 	if (!udev)
 		return USB_SPEED_UNKNOWN;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] usb: dwc3: qcom: check for hcd in dwc3_qcom_read_usb2_speed
  2026-10-22  5:26 [PATCH v3] usb: dwc3: qcom: check for hcd in dwc3_qcom_read_usb2_speed Prashanth K
@ 2026-10-22  5:33 ` sashiko-bot
  2026-10-22  7:37 ` Peter Chen
  1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-10-22  5:33 UTC (permalink / raw)
  To: Prashanth K; +Cc: linux-usb

> 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@oss.qualcomm.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261022052602.2335652-1-prashanth.k@oss.qualcomm.com?part=1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] usb: dwc3: qcom: check for hcd in dwc3_qcom_read_usb2_speed
  2026-10-22  5:26 [PATCH v3] usb: dwc3: qcom: check for hcd in dwc3_qcom_read_usb2_speed Prashanth K
  2026-10-22  5:33 ` sashiko-bot
@ 2026-10-22  7:37 ` Peter Chen
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Chen @ 2026-10-22  7:37 UTC (permalink / raw)
  To: Prashanth K
  Cc: Thinh Nguyen, Greg Kroah-Hartman, linux-usb, linux-kernel,
	Krishna Kurapati

On 26-10-22 10:56:02, Prashanth K wrote:
> 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@oss.qualcomm.com>

Reviewed-by: Peter Chen <peter.chen@oss.qualcomm.com>

Peter
> ---
> Changes in v3: 
>  - Initialised udev to null, as suggested by sashiko bot.
>  - Link to v2: https://lore.kernel.org/all/20261022044748.2303528-1-prashanth.k@oss.qualcomm.com/ 
> 
> 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@oss.qualcomm.com
> 
>  drivers/usb/dwc3/dwc3-qcom.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index ac68b4218b56..e4bf0d5fc9f1 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -231,7 +231,7 @@ static bool dwc3_qcom_is_host(struct dwc3_qcom *qcom)
>  
>  static enum usb_device_speed dwc3_qcom_read_usb2_speed(struct dwc3_qcom *qcom, int port_index)
>  {
> -	struct usb_device *udev;
> +	struct usb_device *udev = NULL;
>  	struct usb_hcd __maybe_unused *hcd;
>  	struct dwc3 *dwc = &qcom->dwc;
>  
> @@ -241,9 +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);
> -#else
> -	udev = NULL;
> +	if (hcd)
> +		udev = usb_hub_find_child(hcd->self.root_hub, port_index + 1);
>  #endif
>  	if (!udev)
>  		return USB_SPEED_UNKNOWN;
> -- 
> 2.34.1
> 
> 

-- 

Thanks,
Peter Chen

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-22  7:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-22  5:26 [PATCH v3] usb: dwc3: qcom: check for hcd in dwc3_qcom_read_usb2_speed Prashanth K
2026-10-22  5:33 ` sashiko-bot
2026-10-22  7:37 ` Peter Chen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.