Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "James Hilliard" <james.hilliard1@gmail.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH net-next 2/3] of: property: link PHY package suppliers to member PHYs
Date: Sun, 16 Aug 2026 00:48:42 +0000	[thread overview]
Message-ID: <20260816004842.C44F01F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260814-submit-phy-package-fwdevlink-v1-v1-2-2319844f057a@gmail.com>

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

Pre-existing issues:
- [High] A malformed devicetree (e.g., placing a `remote-endpoint` property on a node without parents) causes `of_graph_get_port_parent()` to return NULL. This NULL pointer is passed as `con_np` to `of_link_to_phandle()`, which forwards it unmodified to `fwnode_link_add()` and eventually `__fwnode_link_add()`, leading to a kernel panic when dereferenced.
--

--- Patch [2]: [PATCH net-next 2/3] of: property: link PHY package suppliers to member PHYs ---
commit 4b95d666e97ce94700e97701480015a01fd0a0f5
Author: James Hilliard <james.hilliard1@gmail.com>

of: property: link PHY package suppliers to member PHYs

This commit links Ethernet PHY package suppliers directly to their
member PHYs. This prevents proxy links on the MDIO bus from persisting
indefinitely and blocking suppliers from receiving sync_state callbacks.

> diff --git a/drivers/of/property.c b/drivers/of/property.c
> index 72cf12907de03..f29ba818ecbc1 100644
> --- a/drivers/of/property.c
> +++ b/drivers/of/property.c
[ ... ]
> @@ -1272,6 +1272,20 @@ static void of_link_to_phandle(struct device_node *con_np,
>  		tmp_np = of_get_next_parent(tmp_np);
>  	}
>  
> +	/*
> +	 * An Ethernet PHY package node describes resources shared by its member
> +	 * PHYs, but is not populated as a struct device. Link every enabled
> +	 * member PHY to those suppliers so fw_devlink can use the real consumer
> +	 * devices instead of leaving a proxy link on the MDIO bus indefinitely.
> +	 */
> +	if (of_node_name_eq(con_np, "ethernet-phy-package")) {
> +		for_each_available_child_of_node_scoped(con_np, child)
> +			fwnode_link_add(of_fwnode_handle(child),
> +					of_fwnode_handle(sup_np), flags);
> +
> +		return;
> +	}
> +
>  	fwnode_link_add(of_fwnode_handle(con_np), of_fwnode_handle(sup_np), flags);

[Severity: High]
This isn't a bug introduced by this patch, but is it possible for con_np to
be NULL here?

If a malformed devicetree contains a remote-endpoint property on a node
without parents, of_graph_get_port_parent() can return NULL. When fw_devlink
parses this via of_link_property(), it passes this NULL pointer as con_np to
of_link_to_phandle().

The NULL con_np is then forwarded unmodified to fwnode_link_add(), which
eventually reaches __fwnode_link_add() and dereferences the NULL consumer
pointer without validation:

drivers/base/core.c:__fwnode_link_add() {
    ...
    list_add(&link->c_hook, &con->suppliers);
    ...
}

Should there be a check to ensure con_np is valid before attempting to
create the link?

>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260814-submit-phy-package-fwdevlink-v1-v1-0-2319844f057a@gmail.com?part=2

  reply	other threads:[~2026-08-16  0:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-15  0:46 [PATCH net-next 0/3] of: mdio: fix fw_devlink for Ethernet PHY packages James Hilliard
2026-08-15  0:46 ` [PATCH net-next 1/3] driver core: factor sync-state-only link cleanup James Hilliard
2026-08-15  0:46 ` [PATCH net-next 2/3] of: property: link PHY package suppliers to member PHYs James Hilliard
2026-08-16  0:48   ` sashiko-bot [this message]
2026-08-15  0:46 ` [PATCH net-next 3/3] net: mdio: release fw_devlink proxies after population James Hilliard

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=20260816004842.C44F01F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=james.hilliard1@gmail.com \
    --cc=robh@kernel.org \
    --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