Linux-PHY Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Wang Haoran" <wanghr2026@mail.zgclab.edu.cn>
Cc: linux-phy@lists.infradead.org, vkoul@kernel.org,
	neil.armstrong@linaro.org, olteanv@gmail.com
Subject: Re: [PATCH] phy: berlin-sata: count available child nodes
Date: Thu, 19 Nov 2026 08:23:15 +0000	[thread overview]
Message-ID: <sashiko-outbox-222663@kernel.org> (raw)
In-Reply-To: <1795076106646-11-85fca065@mail.zgclab.edu.cn>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] phy: berlin-sata: wrong bounds check in
  phy_berlin_sata_phy_xlate()
--

commit 0529df9ae940f51aa712838077eb6b3ead50665d
Author: Wang Haoran <wanghr2026@mail.zgclab.edu.cn>

phy: berlin-sata: count available child nodes

This commit sizes priv->nphys with of_get_available_child_count() so that
priv->phys[] matches the number of available child nodes populated during
probe.

> diff --git a/drivers/phy/marvell/phy-berlin-sata.c b/drivers/phy/marvell/phy-berlin-sata.c
> index c90e2867900c3..1d3afc2eb9535 100644
> --- a/drivers/phy/marvell/phy-berlin-sata.c
> +++ b/drivers/phy/marvell/phy-berlin-sata.c
> @@ -212,7 +212,7 @@ static int phy_berlin_sata_probe(struct platform_device *pdev)
>  	if (IS_ERR(priv->clk))
>  		return PTR_ERR(priv->clk);
>  
> -	priv->nphys = of_get_child_count(dev->of_node);
> +	priv->nphys = of_get_available_child_count(dev->of_node);
>  	if (priv->nphys == 0)
>  		return -ENODEV;

[Severity: Medium]
Does shrinking priv->nphys to the available child count break lookups of
PHY 1 when PHY 0 is disabled?

drivers/phy/marvell/phy-berlin-sata.c:phy_berlin_sata_phy_xlate() {
    ...
	if (WARN_ON(args->args[0] >= priv->nphys))
		return ERR_PTR(-ENODEV);

	for (i = 0; i < priv->nphys; i++) {
		if (priv->phys[i]->index == args->args[0])
			break;
	}
    ...
}

args->args[0] is the hardware PHY index (0 or 1), which the loop matches
against priv->phys[i]->index.  When PHY 0 is disabled and PHY 1 is enabled,
priv->nphys is 1 and priv->phys[0]->index is 1, so requesting PHY 1 trips
WARN_ON(args->args[0] >= priv->nphys) and fails with -ENODEV before reaching
the lookup loop.

Should phy_berlin_sata_phy_xlate() bound-check args->args[0] against
ARRAY_SIZE(phy_berlin_power_down_bits), matching phy_berlin_sata_probe()?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/1795076106646-11-85fca065@mail.zgclab.edu.cn?part=1

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

      reply	other threads:[~2026-11-19  8:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19  8:15 [PATCH] phy: berlin-sata: count available child nodes Wang Haoran
2026-11-19  8:23 ` 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-222663@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=neil.armstrong@linaro.org \
    --cc=olteanv@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@kernel.org \
    --cc=wanghr2026@mail.zgclab.edu.cn \
    /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