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 2/6] net: dsa: motorcomm: use max_ports in series for port bounds checking
Date: Thu, 03 Dec 2026 08:40:55 +0000	[thread overview]
Message-ID: <sashiko-outbox-247370@kernel.org> (raw)
In-Reply-To: <20261202084022.3716891-3-kyle.switch@motor-comm.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] net: dsa: motorcomm: leak of struct mii_bus in
  yt921x_mbus_int_init()
--

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

net: dsa: motorcomm: use max_ports in series for port bounds checking

This commit replaces the hardcoded YT921X_PORT_NUM constant in internal
MDIO bus operations and setup with the per-series max_ports field, and
validates max_ports before computing mbus->phy_mask.

> diff --git a/drivers/net/dsa/motorcomm/mdio_bus.c b/drivers/net/dsa/motorcomm/mdio_bus.c
> index a4062e6b0f000..a06e2cc94a3e2 100644
> --- a/drivers/net/dsa/motorcomm/mdio_bus.c
> +++ b/drivers/net/dsa/motorcomm/mdio_bus.c
[ ... ]
> @@ -155,6 +155,7 @@ int yt921x_mbus_int_init(struct yt921x_priv *priv, struct device_node *mnp)
>  {
>  	struct device *dev = yt921x_priv_to_device(priv);
>  	struct mii_bus *mbus;
> +	u32 max_ports;
>  	int res;
>  
>  	mbus = mdiobus_alloc();
> @@ -167,7 +168,12 @@ int yt921x_mbus_int_init(struct yt921x_priv *priv, struct device_node *mnp)
>  	mbus->read = yt921x_mbus_int_read;
>  	mbus->write = yt921x_mbus_int_write;
>  	mbus->parent = dev;
> -	mbus->phy_mask = (u32)~GENMASK(YT921X_PORT_NUM - 1, 0);
> +	max_ports = priv->series->max_ports;
> +	if (max_ports == 0 || max_ports > ARRAY_SIZE(priv->ports)) {
> +		dev_err(dev, "Invalid max_ports: %u\n", max_ports);
> +		return -EINVAL;
> +	}

[Severity: Medium]
Does this error path leak mbus?  mbus was allocated with mdiobus_alloc()
above (not devm_mdiobus_alloc()), so returning -EINVAL without calling
mdiobus_free(mbus) or validating max_ports before mdiobus_alloc() leaks
the struct mii_bus.

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

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

Thread overview: 11+ 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-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 [this message]
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-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-02  8:40 ` [PATCH net-next v18 5/6] net: dsa: tag_yt922x: add support for Motorcomm YT922x tags Kyle Switch
2026-12-02  8:40 ` [PATCH net-next v18 6/6] net: dsa: motorcomm: Add support for Motorcomm YT922x Kyle Switch

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-247370@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