Linux USB
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Prashanth K" <prashanth.k@oss.qualcomm.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH v2] usb: dwc3: qcom: check for hcd in dwc3_qcom_read_usb2_speed
Date: Thu, 22 Oct 2026 04:53:14 +0000	[thread overview]
Message-ID: <sashiko-outbox-181008@kernel.org> (raw)
In-Reply-To: <20261022044748.2303528-1-prashanth.k@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] usb: dwc3: qcom: uninitialized udev pointer in dwc3_qcom_read_usb2_speed()
--

commit 9364e775b526fa295084d32e8e9579d5847360c6
Author: Prashanth K <prashanth.k@oss.qualcomm.com>

usb: dwc3: qcom: check for hcd in dwc3_qcom_read_usb2_speed

This commit checks whether hcd is non-NULL in dwc3_qcom_read_usb2_speed()
before dereferencing it to avoid a NULL pointer dereference during system
suspend if xhci_plat_probe() failed.

> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index ac68b4218b56b..6ca51d37c35ac 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

[Severity: High]
In drivers/usb/dwc3/dwc3-qcom.c, dwc3_qcom_read_usb2_speed() declares udev on
the stack without initializing it:

drivers/usb/dwc3/dwc3-qcom.c:dwc3_qcom_read_usb2_speed() {
	struct usb_device *udev;
	struct usb_hcd __maybe_unused *hcd;
	struct dwc3 *dwc = &qcom->dwc;

	hcd = platform_get_drvdata(dwc->xhci);

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

	return udev->speed;
}

When CONFIG_USB is enabled and platform_get_drvdata(dwc->xhci) returns NULL
during dwc3_qcom_pm_suspend() -> dwc3_qcom_read_usb2_speed() (for example,
when xhci_plat_probe() failed), won't udev remain uninitialized and cause
if (!udev) and return udev->speed to read and dereference an uninitialized
pointer?

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

      reply	other threads:[~2026-10-22  4:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-22  4:47 [PATCH v2] usb: dwc3: qcom: check for hcd in dwc3_qcom_read_usb2_speed Prashanth K
2026-10-22  4:53 ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-181008@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=prashanth.k@oss.qualcomm.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox