Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kyle Switch" <kyle.switch@motor-comm.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH net-next v18 6/6] net: dsa: motorcomm: Add support for Motorcomm YT922x
Date: Thu, 03 Dec 2026 08:40:56 +0000	[thread overview]
Message-ID: <sashiko-outbox-247374@kernel.org> (raw)
In-Reply-To: <20261202084022.3716891-7-kyle.switch@motor-comm.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] net: dsa: motorcomm: missing teardown op in
  yt922x_dsa_switch_ops
- [Medium] net: dsa: motorcomm: missing mbus_int cleanup in
  yt922x_dsa_setup()
--

commit f80302457342f670aeeea79ebb7ed0ba554f1c97
Author: Kyle Switch <kyle.switch@motor-comm.com>

net: dsa: motorcomm: Add support for Motorcomm YT922x

This commit adds basic DSA switch, phylink MAC, and SerDes PCS support
for the Motorcomm YT9224 Ethernet switch.

> diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
> index 197dadb1046a4..2a684beac408e 100644
> --- a/drivers/net/dsa/motorcomm/chip.c
> +++ b/drivers/net/dsa/motorcomm/chip.c
[ ... ]
> @@ -2699,6 +2718,480 @@ static const struct dsa_switch_ops yt921x_dsa_switch_ops = {
[ ... ]
> +static int yt922x_dsa_setup(struct dsa_switch *ds)
> +{
> +	struct yt921x_priv *priv = dsa_to_yt921x_priv(ds);
> +	struct device *dev = yt921x_priv_to_device(priv);
> +	struct device_node *np = dev->of_node;
> +	struct device_node *child;
> +	int res;
> +
> +	mutex_lock(&priv->reg_lock);
> +	res = yt921x_chip_reset(priv);
> +	mutex_unlock(&priv->reg_lock);
> +	if (res)
> +		return res;
> +
> +	/* Register the internal mdio bus. */
> +	child = of_get_child_by_name(np, "mdio");
> +	if (child) {
> +		res = yt921x_mbus_int_init(priv, child);
> +		of_node_put(child);
> +		if (res)
> +			return res;
> +	}
> +
> +	mutex_lock(&priv->reg_lock);
> +	res = yt922x_chip_setup(priv);
> +	mutex_unlock(&priv->reg_lock);
> +	if (res)
> +		return res;

[Severity: Medium]
Does this leak priv->mbus_int if yt922x_chip_setup() fails?

yt921x_mbus_int_init() allocates and registers priv->mbus_int with
non-devm mdiobus_alloc() and of_mdiobus_register().  Because
dsa_switch_setup() does not call ds->ops->teardown when ds->ops->setup
fails, returning directly here leaves the MDIO bus registered with
mbus->priv pointing to priv after yt921x_mdio_probe() fails and devres
frees priv.  Unlike yt921x_dsa_setup(), this error path does not call
yt921x_mbus_int_cleanup(priv).

> +
> +	/* switch sds pcs setup */
> +	yt922x_pcs_setup(ds);
> +
> +	return 0;
> +}
> +
> +static const struct dsa_switch_ops yt922x_dsa_switch_ops = {
> +	/* port */
> +	.get_tag_protocol = yt922x_dsa_get_tag_protocol,
> +	.phylink_get_caps = yt922x_dsa_phylink_get_caps,
> +	.port_setup  = yt922x_dsa_port_setup,
> +	/* chip */
> +	.setup   = yt922x_dsa_setup,
> +};

[Severity: High]
Should yt922x_dsa_switch_ops set .teardown to clean up priv->mbus_int?

Without .teardown, dsa_switch_teardown() never unregisters or frees
priv->mbus_int when the switch is removed in yt921x_mdio_remove() or
when dsa_register_switch() fails after setup.  On driver unbind,
yt921x_mdio_remove() destroys priv->reg_lock and devres frees priv while
priv->mbus_int remains live in the MDIO subsystem, causing a
use-after-free in yt921x_mbus_int_read() and yt921x_mbus_int_write().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202084022.3716891-1-kyle.switch@motor-comm.com?part=6

  reply	other threads:[~2026-12-03  8:40 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  8:40 [PATCH net-next v18 0/6] net: dsa: motorcomm: add support yt922x driver Kyle Switch
2026-12-02  8:40 ` [PATCH net-next v18 1/6] net: dsa: motorcomm: initialize dsa_switch based on chipid Kyle Switch
2026-12-03  8:40   ` sashiko-bot
2026-12-03  8:57   ` netdev-bot+sashiko
2026-12-02  8:40 ` [PATCH net-next v18 2/6] net: dsa: motorcomm: use max_ports in series for port bounds checking Kyle Switch
2026-12-03  8:40   ` sashiko-bot
2026-12-03  8:57   ` netdev-bot+sashiko
2026-12-02  8:40 ` [PATCH net-next v18 3/6] net: dsa: motorcomm: use GENMASK_U32() for mbus phy_mask Kyle Switch
2026-12-03  8:57   ` netdev-bot+sashiko
2026-12-02  8:40 ` [PATCH net-next v18 4/6] dt-bindings: net: dsa: add Motorcomm YT9224 Kyle Switch
2026-12-02 22:58   ` Rob Herring (Arm)
2026-12-03  8:40   ` sashiko-bot
2026-12-03  8:57   ` netdev-bot+sashiko
2026-12-02  8:40 ` [PATCH net-next v18 5/6] net: dsa: tag_yt922x: add support for Motorcomm YT922x tags Kyle Switch
2026-12-03  8:57   ` netdev-bot+sashiko
2026-12-02  8:40 ` [PATCH net-next v18 6/6] net: dsa: motorcomm: Add support for Motorcomm YT922x Kyle Switch
2026-12-03  8:40   ` sashiko-bot [this message]
2026-12-03  8:57   ` 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=sashiko-outbox-247374@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=kyle.switch@motor-comm.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