All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Joris Vaisvila" <joey@tinyisr.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH net-next v4 4/4] net: dsa: initial support for MT7628 embedded switch
Date: Tue, 09 Jun 2026 19:31:06 +0000	[thread overview]
Message-ID: <20260609193107.088241F00899@smtp.kernel.org> (raw)
In-Reply-To: <20260608192948.289745-5-joey@tinyisr.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Using devm_mdiobus_alloc() and devm_mdiobus_register() within the DSA .setup() callback causes memory leaks and sysfs naming collisions on device unbind/rebind.
--

commit 3622b1e586d001c3ba3f067ff8677605bcde34cc
Author: Joris Vaisvila <joey@tinyisr.com>

net: dsa: initial support for MT7628 embedded switch

This commit adds support for the MT7628 embedded switch, which includes 5 user
ports and 1 CPU port. It uses a 16-entry VLAN table for port isolation and
configures a double tag feature to simulate VLAN-unaware functionality.

> diff --git a/drivers/net/dsa/mt7628.c b/drivers/net/dsa/mt7628.c
> new file mode 100644
> index 0000000000000..a2338f02f78a0
> --- /dev/null
> +++ b/drivers/net/dsa/mt7628.c
> @@ -0,0 +1,648 @@
[ ... ]
> +static int mt7628_setup_internal_mdio(struct dsa_switch *ds)
> +{
> +	struct mt7628_esw *esw = ds->priv;
> +	struct mii_bus *bus;
> +
> +	bus = devm_mdiobus_alloc(esw->dev);
> +	if (!bus)
> +		return -ENOMEM;
> +
> +	bus->name = "MT7628 internal MDIO bus";
> +	snprintf(bus->id, MII_BUS_ID_SIZE, "%s-mii", dev_name(esw->dev));
> +	bus->priv = esw;
> +	bus->read = mt7628_mii_read;
> +	bus->write = mt7628_mii_write;
> +	bus->parent = esw->dev;
> +
> +	ds->user_mii_bus = bus;
> +	bus->phy_mask = ~ds->phys_mii_mask;
> +
> +	return devm_mdiobus_register(esw->dev, bus);

[Severity: High]
Is it safe to use devm_mdiobus_alloc() and devm_mdiobus_register() tied to
the platform device here?

Since mt7628_setup_internal_mdio() is called from the DSA .setup() callback
below, it can be executed multiple times without the platform device unbinding
(for instance, when the conduit interface unbinds and rebinds).

Because the devm_ functions tie the MDIO bus allocation and registration to
the platform device, the bus is never unregistered or freed during the DSA
.teardown() phase.

When the tree is re-setup, won't it attempt to register a new MDIO bus with
the same ID, causing a sysfs name collision and resource leak?

[ ... ]
> +static int mt7628_setup(struct dsa_switch *ds)
> +{
> +	struct mt7628_esw *esw = ds->priv;
> +	int ret;
[ ... ]
> +	mt7628_switch_init(ds);
> +
> +	ret = mt7628_setup_internal_mdio(ds);
> +	if (ret)
> +		return ret;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260608192948.289745-1-joey@tinyisr.com?part=4

      reply	other threads:[~2026-06-09 19:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-08 19:29 [PATCH net-next v4 0/4] net: dsa: mt7628 embedded switch initial support Joris Vaisvila
2026-06-08 19:29 ` [PATCH net-next v4 1/4] dt-bindings: net: dsa: add MT7628 ESW Joris Vaisvila
2026-06-09  7:01   ` Krzysztof Kozlowski
2026-06-08 19:29 ` [PATCH net-next v4 2/4] net: phy: mediatek: add phy driver for MT7628 built-in Fast Ethernet PHYs Joris Vaisvila
2026-06-09 19:31   ` sashiko-bot
2026-06-08 19:29 ` [PATCH net-next v4 3/4] net: dsa: initial MT7628 tagging driver Joris Vaisvila
2026-06-08 19:29 ` [PATCH net-next v4 4/4] net: dsa: initial support for MT7628 embedded switch Joris Vaisvila
2026-06-09 19:31   ` 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=20260609193107.088241F00899@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=joey@tinyisr.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.