Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Christian Marangi" <ansuelsmth@gmail.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org, mfd@lists.linux.dev,
	lee@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH net-next v23 4/9] mfd: an8855: Add support for Airoha AN8855 Switch
Date: Sat, 26 Sep 2026 18:25:17 +0000	[thread overview]
Message-ID: <20260926182518.3A2601F0089A@smtp.kernel.org> (raw)
In-Reply-To: <20260925182435.21207-5-ansuelsmth@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] of: memory leak of mdio_np in an8855_mdio_register error path
- [Medium] mfd: sysfs naming collision for virtual MDIO bus with multiple switches
--

commit 802b31a10a6859408359f548c9b38d422fd3e7dc
Author: Christian Marangi <ansuelsmth@gmail.com>
Subject: mfd: an8855: Add support for Airoha AN8855 Switch

Add support for Airoha AN8855 Switch that provide support for a DSA
switch and a NVMEM provider. Also make use of the mdio-regmap driver
and register a regmap for each internal PHY of the switch.

> diff --git a/drivers/mfd/airoha-an8855.c b/drivers/mfd/airoha-an8855.c
> new file mode 100644
> index 0000000000000..a2a36704a9fca
> --- /dev/null
> +++ b/drivers/mfd/airoha-an8855.c
[ ... ]
> +static int an8855_phy_bus_register(struct device *dev, struct an8855_core_priv *priv,
> +				   struct device_node *phy_np,
> +				   struct an8855_phy_bus *phy_bus_info)
> +{
[ ... ]
> +	mrc.regmap = regmap;
> +	mrc.parent = dev;
> +	mrc.valid_addr = addr;
> +	snprintf(mrc.name, MII_BUS_ID_SIZE, "an8855:%u-phy%u", priv->switch_addr,
> +		 phy_offset);

[Severity: Medium]
Will this static naming scheme fail to disambiguate virtual buses across
multiple independent parent devices?

If a system contains multiple AN8855 switches on different MDIO buses but
configured at the same MDIO address (e.g., address 0), priv->switch_addr
will be identical for both.

Since devm_mdio_regmap_register attempts to register both virtual buses with
the exact same name (e.g., an8855:0-phy0), would this lead to a sysfs naming
collision and cause the second switch to fail probe? A parent device
identifier like dev_name(dev) might be needed to ensure uniqueness.

> +
> +	bus = devm_mdio_regmap_register(dev, &mrc);
[ ... ]
> +static int an8855_mdio_register(struct device *dev, struct an8855_core_priv *priv,
> +				struct an8855_phy_bus *phy_bus_infos)
> +{
> +	struct device_node *mdio_np;
> +	int ret = 0;
> +	int i = 0;
> +
> +	mdio_np = of_get_child_by_name(dev->of_node, "mdio");

[Severity: Medium]
Does this code leak the mdio_np device node on the error path?

of_get_child_by_name dynamically acquires and increments the reference
count of the returned device node mdio_np.

> +	if (!mdio_np)
> +		return -ENODEV;
> +
> +	for_each_available_child_of_node_scoped(mdio_np, phy_np) {
> +		if (i >= AN8855_MAX_PHY_PORT) {
> +			ret = -EINVAL;
> +			goto exit;
> +		}
> +
> +		ret = an8855_phy_bus_register(dev, priv, phy_np,
> +					      &phy_bus_infos[i]);
> +		if (ret)
> +			goto exit;
> +
> +		i++;
> +	}
> +
> +	of_node_put(mdio_np);
> +exit:

In the normal execution path, of_node_put(mdio_np) is correctly called.
However, if an error occurs during child node iteration, the code executes
goto exit, which jumps directly to the cleanup block and bypasses
of_node_put(mdio_np), leaving the reference count incremented.

> +	if (ret) {
> +		while (i--)
> +			fwnode_handle_put(phy_bus_infos[i].node);
> +
> +		return ret;
> +	}
> +
> +	return i;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260925182435.21207-1-ansuelsmth@gmail.com?part=4

  reply	other threads:[~2026-09-26 18:25 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-25 18:24 [PATCH net-next v23 0/9] net: dsa: Add Airoha AN8855 support Christian Marangi
2026-09-25 18:24 ` [PATCH net-next v23 1/9] dt-bindings: net: dsa: Document support for Airoha AN8855 DSA Switch Christian Marangi
2026-09-26 18:25   ` sashiko-bot
2026-09-25 18:24 ` [PATCH net-next v23 2/9] dt-bindings: net: Document support for AN8855 Switch Internal PHY Christian Marangi
2026-09-26 18:25   ` sashiko-bot
2026-09-29 20:34   ` netdev-bot+sashiko
2026-09-25 18:24 ` [PATCH net-next v23 3/9] dt-bindings: mfd: Document support for Airoha AN8855 Switch SoC Christian Marangi
2026-09-26 18:25   ` sashiko-bot
2026-09-29 20:35   ` netdev-bot+sashiko
2026-09-25 18:24 ` [PATCH net-next v23 4/9] mfd: an8855: Add support for Airoha AN8855 Switch Christian Marangi
2026-09-26 18:25   ` sashiko-bot [this message]
2026-09-29 20:35   ` netdev-bot+sashiko
2026-09-25 18:24 ` [PATCH net-next v23 5/9] net: phy: Add Airoha AN8855 Internal Switch Gigabit PHY Christian Marangi
2026-09-26 18:25   ` sashiko-bot
2026-09-27 18:45   ` Andrew Lunn
2026-09-29 20:35   ` netdev-bot+sashiko
2026-09-25 18:24 ` [PATCH net-next v23 6/9] net: dsa: tag_mtk: add Airoha variant usage of this TAG Christian Marangi
2026-09-26 18:25   ` sashiko-bot
2026-09-27 18:49   ` Andrew Lunn
2026-09-29 20:35   ` netdev-bot+sashiko
2026-09-25 18:24 ` [PATCH net-next v23 7/9] MAINTAINERS: add myself as maintainer for Airoha AN8855 Switch Christian Marangi
2026-09-27 18:51   ` Andrew Lunn
2026-09-25 18:24 ` [PATCH net-next v23 8/9] net: dsa: mt7530: generalize and move common function to lib module Christian Marangi
2026-09-26 18:25   ` sashiko-bot
2026-09-27 19:02   ` Andrew Lunn
2026-09-27 20:28     ` Christian Marangi
2026-09-27 21:48       ` Andrew Lunn
2026-09-29 20:35   ` netdev-bot+sashiko
2026-09-25 18:24 ` [PATCH net-next v23 9/9] net: dsa: Add Airoha AN8855 5-Port Gigabit DSA Switch driver Christian Marangi
2026-09-26 18:25   ` sashiko-bot
2026-09-27 19:15   ` Andrew Lunn
2026-09-29 20:35   ` netdev-bot+sashiko

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=20260926182518.3A2601F0089A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=ansuelsmth@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=lee@kernel.org \
    --cc=mfd@lists.linux.dev \
    --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