All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Krishna Kurapati" <krishna.kurapati@oss.qualcomm.com>
Cc: linux-phy@lists.infradead.org, olteanv@gmail.com,
	robh@kernel.org, devicetree@vger.kernel.org,
	neil.armstrong@linaro.org, conor+dt@kernel.org, vkoul@kernel.org
Subject: Re: [PATCH v8 5/5] usb: dwc3: qcom: Modify interrupt handling for eUSB2 Phy targets
Date: Sun, 13 Sep 2026 14:53:15 +0000	[thread overview]
Message-ID: <20260913145315.BD2A51F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260913-eusb2-interrupt-v8-v8-5-0f505b9c394b@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [High] Probe fails unconditionally if CONFIG_GENERIC_PHY is disabled because the error check misses -ENOSYS.

Pre-existing issues:
- [High] Missing lock and lifecycle protection when accessing xHCI drvdata leads to NULL pointer dereference during concurrent driver unbind.
--

commit fda37af83fa24f9ca3c0472a4d6f4d45d01b3ce6
Author: Krishna Kurapati <krishna.kurapati@oss.qualcomm.com>

usb: dwc3: qcom: Modify interrupt handling for eUSB2 Phy targets

This patch modifies the interrupt handling for eUSB2 PHY targets in host
mode to configure wakeup interrupts differently based on the connected device
speed. The driver now queries the PHY type and configures DP/DM edge
interrupts accordingly.

> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index ac68b4218b56b..e6b6beb38fcba 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
[ ... ]
> @@ -683,6 +705,17 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
>  	if (ignore_pipe_clk)
>  		dwc3_qcom_select_utmi_clk(qcom);
>  
> +	phy = devm_of_phy_get_by_index(dev, dev->of_node, 0);
> +	if (IS_ERR(phy)) {
> +		if (PTR_ERR(phy) != -ENODEV) {

[Severity: High]
Will this unconditionally fail to probe when CONFIG_GENERIC_PHY is disabled?

If the kernel is built without generic PHY support, devm_of_phy_get_by_index()
returns ERR_PTR(-ENOSYS). Since this check only allows -ENODEV as a benign
error, an -ENOSYS return will cause the driver to invoke dev_err_probe() and
abort initialization.

Should this check also handle -ENOSYS to allow graceful fallback when
the PHY subsystem is disabled, similar to how the DWC3 core handles it?
(e.g., if (PTR_ERR(phy) != -ENODEV && PTR_ERR(phy) != -ENOSYS))

> +			ret = dev_err_probe(dev, PTR_ERR(phy),
> +					    "failed to get usb2 phy\n");
> +			goto clk_disable;
> +		}
> +		phy = NULL;
> +	}
> +	qcom->has_eusb2_phy = (phy_get_type(phy) == PHY_TYPE_EUSB2);
> +
>  	qcom->mode = usb_get_dr_mode(dev);

While reviewing the driver context, I noticed a pre-existing issue in the
surrounding codebase:

drivers/usb/dwc3/dwc3-qcom.c:dwc3_qcom_read_usb2_speed() {
    ...
	/*
	 * FIXME: Fix this layering violation.
	 */
	hcd = platform_get_drvdata(dwc->xhci);

#ifdef CONFIG_USB
	udev = usb_hub_find_child(hcd->self.root_hub, port_index + 1);
    ...
}

[Severity: High]
This isn't a bug introduced by this patch, but does this missing lifecycle
protection for the xHCI drvdata lead to a NULL pointer dereference?

If the child xhci-plat driver fails to probe, or if a user unbinds it via sysfs
(e.g., echo xhci-hcd > /sys/bus/platform/drivers/xhci-hcd/unbind), the driver
core calls dev_set_drvdata(dev, NULL). This releases the PM usage count and
causes the parent dwc3-qcom controller to enter runtime suspend.

When dwc3_qcom_runtime_suspend() then calls dwc3_qcom_read_usb2_speed(), it
blindly retrieves the now-NULL drvdata via platform_get_drvdata() and
immediately dereferences it when accessing hcd->self.root_hub.

Could this race condition trigger a kernel panic during a concurrent driver
unbind?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260913-eusb2-interrupt-v8-v8-0-0f505b9c394b@oss.qualcomm.com?part=5

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: "Krishna Kurapati" <krishna.kurapati@oss.qualcomm.com>
Cc: linux-phy@lists.infradead.org, olteanv@gmail.com,
	robh@kernel.org, devicetree@vger.kernel.org,
	neil.armstrong@linaro.org, conor+dt@kernel.org, vkoul@kernel.org
Subject: Re: [PATCH v8 5/5] usb: dwc3: qcom: Modify interrupt handling for eUSB2 Phy targets
Date: Sun, 13 Sep 2026 14:53:15 +0000	[thread overview]
Message-ID: <20260913145315.BD2A51F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260913-eusb2-interrupt-v8-v8-5-0f505b9c394b@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [High] Probe fails unconditionally if CONFIG_GENERIC_PHY is disabled because the error check misses -ENOSYS.

Pre-existing issues:
- [High] Missing lock and lifecycle protection when accessing xHCI drvdata leads to NULL pointer dereference during concurrent driver unbind.
--

commit fda37af83fa24f9ca3c0472a4d6f4d45d01b3ce6
Author: Krishna Kurapati <krishna.kurapati@oss.qualcomm.com>

usb: dwc3: qcom: Modify interrupt handling for eUSB2 Phy targets

This patch modifies the interrupt handling for eUSB2 PHY targets in host
mode to configure wakeup interrupts differently based on the connected device
speed. The driver now queries the PHY type and configures DP/DM edge
interrupts accordingly.

> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index ac68b4218b56b..e6b6beb38fcba 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
[ ... ]
> @@ -683,6 +705,17 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
>  	if (ignore_pipe_clk)
>  		dwc3_qcom_select_utmi_clk(qcom);
>  
> +	phy = devm_of_phy_get_by_index(dev, dev->of_node, 0);
> +	if (IS_ERR(phy)) {
> +		if (PTR_ERR(phy) != -ENODEV) {

[Severity: High]
Will this unconditionally fail to probe when CONFIG_GENERIC_PHY is disabled?

If the kernel is built without generic PHY support, devm_of_phy_get_by_index()
returns ERR_PTR(-ENOSYS). Since this check only allows -ENODEV as a benign
error, an -ENOSYS return will cause the driver to invoke dev_err_probe() and
abort initialization.

Should this check also handle -ENOSYS to allow graceful fallback when
the PHY subsystem is disabled, similar to how the DWC3 core handles it?
(e.g., if (PTR_ERR(phy) != -ENODEV && PTR_ERR(phy) != -ENOSYS))

> +			ret = dev_err_probe(dev, PTR_ERR(phy),
> +					    "failed to get usb2 phy\n");
> +			goto clk_disable;
> +		}
> +		phy = NULL;
> +	}
> +	qcom->has_eusb2_phy = (phy_get_type(phy) == PHY_TYPE_EUSB2);
> +
>  	qcom->mode = usb_get_dr_mode(dev);

While reviewing the driver context, I noticed a pre-existing issue in the
surrounding codebase:

drivers/usb/dwc3/dwc3-qcom.c:dwc3_qcom_read_usb2_speed() {
    ...
	/*
	 * FIXME: Fix this layering violation.
	 */
	hcd = platform_get_drvdata(dwc->xhci);

#ifdef CONFIG_USB
	udev = usb_hub_find_child(hcd->self.root_hub, port_index + 1);
    ...
}

[Severity: High]
This isn't a bug introduced by this patch, but does this missing lifecycle
protection for the xHCI drvdata lead to a NULL pointer dereference?

If the child xhci-plat driver fails to probe, or if a user unbinds it via sysfs
(e.g., echo xhci-hcd > /sys/bus/platform/drivers/xhci-hcd/unbind), the driver
core calls dev_set_drvdata(dev, NULL). This releases the PM usage count and
causes the parent dwc3-qcom controller to enter runtime suspend.

When dwc3_qcom_runtime_suspend() then calls dwc3_qcom_read_usb2_speed(), it
blindly retrieves the now-NULL drvdata via platform_get_drvdata() and
immediately dereferences it when accessing hcd->self.root_hub.

Could this race condition trigger a kernel panic during a concurrent driver
unbind?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260913-eusb2-interrupt-v8-v8-0-0f505b9c394b@oss.qualcomm.com?part=5

  reply	other threads:[~2026-09-13 14:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-13 14:40 [PATCH v8 0/5] Modify interrupt handling for eUSB2 Phy targets Krishna Kurapati
2026-09-13 14:40 ` Krishna Kurapati
2026-09-13 14:40 ` [PATCH v8 1/5] dt-bindings: phy: Add PHY_TYPE_EUSB2 definition Krishna Kurapati
2026-09-13 14:40   ` Krishna Kurapati
2026-09-13 14:40 ` [PATCH v8 2/5] include: linux: phy: Add phy attribute "type" and associated helpers Krishna Kurapati
2026-09-13 14:40   ` Krishna Kurapati
2026-09-13 14:40 ` [PATCH v8 3/5] phy: snps-eusb2: Set phy type to EUSB2 Krishna Kurapati
2026-09-13 14:40   ` Krishna Kurapati
2026-09-13 14:40 ` [PATCH v8 4/5] phy: qcom: m31-eusb2: " Krishna Kurapati
2026-09-13 14:40   ` Krishna Kurapati
2026-09-13 14:40 ` [PATCH v8 5/5] usb: dwc3: qcom: Modify interrupt handling for eUSB2 Phy targets Krishna Kurapati
2026-09-13 14:40   ` Krishna Kurapati
2026-09-13 14:53   ` sashiko-bot [this message]
2026-09-13 14:53     ` sashiko-bot

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=20260913145315.BD2A51F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krishna.kurapati@oss.qualcomm.com \
    --cc=linux-phy@lists.infradead.org \
    --cc=neil.armstrong@linaro.org \
    --cc=olteanv@gmail.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@kernel.org \
    /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 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.