Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mohd Ayaan Anwar" <mohd.anwar@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, linux-phy@lists.infradead.org,
	vkoul@kernel.org, robh@kernel.org, conor+dt@kernel.org,
	neil.armstrong@linaro.org, olteanv@gmail.com
Subject: Re: [PATCH v2 2/6] phy: qcom: sgmii-eth: vote for both voltage rails with correct current loads
Date: Mon, 03 Aug 2026 19:38:33 +0000	[thread overview]
Message-ID: <20260803193833.ECF8D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260804-b4-sgmiieth_serdes_regulator-v2-2-c4bc688177dd@oss.qualcomm.com>

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

Pre-existing issues:
- [High] The PHY provider is registered before its driver data is set, creating a race condition where a consumer could trigger a NULL pointer dereference.
--

--- Patch [2]: [PATCH v2 2/6] phy: qcom: sgmii-eth: vote for both voltage rails with correct current loads ---
commit 1203fb5a9ba082470a0383befe64f62c484ac7d5
Author: Mohd Ayaan Anwar <mohd.anwar@oss.qualcomm.com>

phy: qcom: sgmii-eth: vote for both voltage rails with correct current loads

This commit updates the driver to explicitly vote for both voltage supply
rails with their correct peak current loads using
devm_regulator_bulk_get_const(), rather than relying on the PHY framework's
implicit single-rail voting. It also adds the necessary regulator
enable/disable calls in the power path.

> diff --git a/drivers/phy/qualcomm/phy-qcom-sgmii-eth.c b/drivers/phy/qualcomm/phy-qcom-sgmii-eth.c
> index f48faa2929a68..7137200c3f310 100644
> --- a/drivers/phy/qualcomm/phy-qcom-sgmii-eth.c
> +++ b/drivers/phy/qualcomm/phy-qcom-sgmii-eth.c

[ ... ]

> @@ -381,6 +404,12 @@ static int qcom_dwmac_sgmii_phy_probe(struct platform_device *pdev)
>  	if (IS_ERR(data->refclk))
>  		return PTR_ERR(data->refclk);
>  
> +	ret = devm_regulator_bulk_get_const(dev, QCOM_SGMII_NUM_SUPPLIES,
> +					    qcom_dwmac_sgmii_phy_vregs,
> +					    &data->vregs);
> +	if (ret)
> +		return ret;
> +
>  	provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
>  	if (IS_ERR(provider))
>  		return PTR_ERR(provider);

[Severity: High]
This is a pre-existing issue, but does registering the PHY provider before
setting the driver data create a race condition here?

Looking at the end of qcom_dwmac_sgmii_phy_probe():

	provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
	if (IS_ERR(provider))
		return PTR_ERR(provider);

	phy_set_drvdata(phy, data);

By calling devm_of_phy_provider_register() first, the PHY is made available
to consumers before phy_set_drvdata() initializes the private data.

If a consumer (such as a deferred probe workqueue) concurrently looks up the
PHY and immediately invokes an operation like phy_power_on(), could
qcom_dwmac_sgmii_phy_power_on() read a NULL driver data pointer and cause
a NULL pointer dereference when attempting to access data->vregs?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260804-b4-sgmiieth_serdes_regulator-v2-0-c4bc688177dd@oss.qualcomm.com?part=2

  reply	other threads:[~2026-08-03 19:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03 19:27 [PATCH v2 0/6] Fix regulator voting for the Qualcomm SGMII SerDes PHY Mohd Ayaan Anwar
2026-08-03 19:27 ` [PATCH v2 1/6] dt-bindings: phy: qcom,sa8775p-dwmac-sgmii-phy: add named voltage rails and deprecate phy-supply Mohd Ayaan Anwar
2026-08-03 19:36   ` sashiko-bot
2026-08-04  6:19   ` Krzysztof Kozlowski
2026-08-03 19:27 ` [PATCH v2 2/6] phy: qcom: sgmii-eth: vote for both voltage rails with correct current loads Mohd Ayaan Anwar
2026-08-03 19:38   ` sashiko-bot [this message]
2026-08-03 19:27 ` [PATCH v2 3/6] arm64: dts: qcom: lemans-evk: fix SerDes PHY regulator supplies Mohd Ayaan Anwar
2026-08-03 19:37   ` sashiko-bot
2026-08-03 19:28 ` [PATCH v2 4/6] arm64: dts: qcom: lemans-ride-common: " Mohd Ayaan Anwar
2026-08-03 19:43   ` sashiko-bot
2026-08-03 19:28 ` [PATCH v2 5/6] arm64: dts: qcom: monaco-evk: " Mohd Ayaan Anwar
2026-08-03 19:47   ` sashiko-bot
2026-08-03 19:28 ` [PATCH v2 6/6] arm64: dts: qcom: qcs8300-ride: " Mohd Ayaan Anwar
2026-08-03 19:36   ` sashiko-bot
2026-08-04  8:36 ` [PATCH v2 0/6] Fix regulator voting for the Qualcomm SGMII SerDes PHY Mohd Ayaan Anwar

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=20260803193833.ECF8D1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=mohd.anwar@oss.qualcomm.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox