From: sashiko-bot@kernel.org
To: "Vladimir Oltean" <vladimir.oltean@nxp.com>
Cc: vkoul@kernel.org, linux-phy@lists.infradead.org,
olteanv@gmail.com, neil.armstrong@linaro.org
Subject: Re: [PATCH v2 phy-next 01/15] phy: lynx-28g: reject probing on devices with unsupported OF nodes
Date: Fri, 29 May 2026 17:35:43 +0000 [thread overview]
Message-ID: <20260529173544.908FE1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260529171509.1163787-2-vladimir.oltean@nxp.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] The lynx_28g_xlate callback can return NULL for uninitialized PHY lanes, leading to a NULL pointer dereference in the PHY framework.
- [High] The PHY device retains a pointer to an OF child node after its reference count has been dropped, leading to a potential Use-After-Free.
--
commit 74be4f3f82272eac244d345f53d8340e9a230084
Author: Vladimir Oltean <vladimir.oltean@nxp.com>
phy: lynx-28g: reject probing on devices with unsupported OF nodes
This patch fixes a crash triggered via the driver_override mechanism when
of_device_get_match_data() returns NULL for a device with a different
compatible string. It adds a check to return -ENODEV if the match data
is missing.
> diff --git a/drivers/phy/freescale/phy-fsl-lynx-28g.c b/drivers/phy/freescale/phy-fsl-lynx-28g.c
> index 92bfc5f65e0b8..4461b47a16ad6 100644
> --- a/drivers/phy/freescale/phy-fsl-lynx-28g.c
> +++ b/drivers/phy/freescale/phy-fsl-lynx-28g.c
> @@ -1477,6 +1477,9 @@ static int lynx_28g_probe(struct platform_device *pdev)
>
> priv->dev = dev;
> priv->info = of_device_get_match_data(dev);
> + if (!priv->info)
> + return -ENODEV;
> +
> dev_set_drvdata(dev, priv);
> spin_lock_init(&priv->pcc_lock);
> INIT_DELAYED_WORK(&priv->cdr_check, lynx_28g_cdr_lock_check);
[Severity: High]
This isn't a bug introduced by this patch, but does this function leave the
PHY device with a pointer to a freed child node later in the probe process?
Further down in lynx_28g_probe():
for_each_available_child_of_node(dn, child) {
...
err = lynx_28g_probe_lane(priv, reg, child);
...
The for_each_available_child_of_node() macro automatically handles
reference counting for the child node.
When lynx_28g_probe_lane() creates the PHY, phy_create() stores this
child node in phy->dev.of_node, but it does not call of_node_get() to
acquire an additional reference.
Once the loop advances, the iterator automatically calls of_node_put(),
dropping the reference. If the node is later dynamically freed, such as
during a DT overlay unload, could this cause a use-after-free when
phy->dev.of_node is accessed?
[Severity: High]
This is a pre-existing issue, but can the xlate callback return NULL for
uninitialized PHY lanes and cause a crash in the PHY framework?
If a requested lane index is within bounds but the lane was not probed
(due to a missing subnode in the device tree), priv->lane[idx].phy remains
NULL and is returned directly by lynx_28g_xlate().
When this NULL is passed to of_phy_get() by _of_phy_get():
drivers/phy/phy-core.c:of_phy_get() {
...
if (IS_ERR(phy))
return phy;
if (!try_module_get(phy->ops->owner))
...
}
Since IS_ERR(NULL) evaluates to false, it proceeds to dereference the NULL
pointer via phy->ops->owner. Should the callback return ERR_PTR(-ENODEV)
instead for missing lanes?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260529171509.1163787-1-vladimir.oltean@nxp.com?part=1
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
next prev parent reply other threads:[~2026-05-29 17:35 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-29 17:14 [PATCH v2 phy-next 00/15] New Generic PHY driver for Lynx 10G SerDes Vladimir Oltean
2026-05-29 17:14 ` [PATCH v2 phy-next 01/15] phy: lynx-28g: reject probing on devices with unsupported OF nodes Vladimir Oltean
2026-05-29 17:35 ` sashiko-bot [this message]
2026-05-29 17:14 ` [PATCH v2 phy-next 02/15] phy: lynx-28g: move lane mode helpers to new core module Vladimir Oltean
2026-05-29 17:27 ` sashiko-bot
2026-05-29 17:14 ` [PATCH v2 phy-next 03/15] phy: lynx-28g: move data structures to core Vladimir Oltean
2026-05-29 17:14 ` [PATCH v2 phy-next 04/15] phy: lynx-28g: common lynx_pll_get() Vladimir Oltean
2026-05-29 17:14 ` [PATCH v2 phy-next 05/15] phy: lynx-28g: generalize protocol converter accessors Vladimir Oltean
2026-05-29 17:15 ` [PATCH v2 phy-next 06/15] phy: lynx-28g: provide default lynx_lane_supports_mode() implementation Vladimir Oltean
2026-05-29 17:15 ` [PATCH v2 phy-next 07/15] phy: lynx-28g: move struct lynx_info definitions downwards Vladimir Oltean
2026-05-29 17:15 ` [PATCH v2 phy-next 08/15] phy: lynx-28g: make lynx_28g_pll_read_configuration() callable per PLL Vladimir Oltean
2026-05-29 17:15 ` [PATCH v2 phy-next 09/15] phy: lynx-28g: common probe() and remove() Vladimir Oltean
2026-05-29 17:15 ` [PATCH v2 phy-next 10/15] phy: lynx-28g: add support for big endian register maps Vladimir Oltean
2026-05-29 17:15 ` [PATCH v2 phy-next 11/15] phy: lynx-28g: optimize read-modify-write operation Vladimir Oltean
2026-05-29 17:15 ` [PATCH v2 phy-next 12/15] phy: lynx-28g: improve phy_validate() procedure Vladimir Oltean
2026-05-29 17:15 ` [PATCH v2 phy-next 13/15] dt-bindings: phy: lynx-10g: initial document Vladimir Oltean
2026-05-29 17:15 ` [PATCH v2 phy-next 14/15] phy: lynx-10g: new driver Vladimir Oltean
2026-05-29 18:21 ` sashiko-bot
2026-05-29 17:15 ` [PATCH v2 phy-next 15/15] MAINTAINERS: expand Lynx 28G entry to cover Lynx 10G SerDes Vladimir Oltean
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=20260529173544.908FE1F00893@smtp.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=vladimir.oltean@nxp.com \
/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