From: sashiko-bot@kernel.org
To: "Wei Fang" <wei.fang@nxp.com>
Cc: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
Frank.Li@kernel.org, imx@lists.linux.dev,
devicetree@vger.kernel.org
Subject: Re: [PATCH v7 net-next 10/15] net: dsa: netc: introduce NXP NETC switch driver for i.MX94
Date: Thu, 14 May 2026 05:57:15 +0000 [thread overview]
Message-ID: <20260514055715.A004FC2BCB7@smtp.kernel.org> (raw)
In-Reply-To: <20260513030454.1666570-11-wei.fang@nxp.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Resource leaks and sysfs duplication upon DSA master interface unbind/rebind due to misuse of `devm_*` APIs in the `.setup` callback.
- [Medium] Missing `pci_clear_master()` in the `.shutdown` callback risks memory corruption during kexec.
--
commit 61a3ea3e0b6e78c0e019f8c93113e82986d40e5e
Author: Wei Fang <wei.fang@nxp.com>
Subject: net: dsa: netc: introduce NXP NETC switch driver for i.MX94
This commit introduces the initial NXP NETC switch driver for the i.MX94
series, providing basic probe and remove functionality. The NETC IP provides
integrated 802.1Q Ethernet switch functionality and internal ENETC
connectivity via a pseudo MAC.
> diff --git a/drivers/net/dsa/netc/netc_main.c b/drivers/net/dsa/netc/netc_main.c
> index 0000000000000..8e3a3230226c3
> --- /dev/null
> +++ b/drivers/net/dsa/netc/netc_main.c
[ ... ]
> +static int netc_port_create_emdio_bus(struct netc_port *np,
> + struct device_node *node)
> +{
[ ... ]
> + bus = devm_mdiobus_alloc_size(dev, sizeof(*mdio_priv));
> + if (!bus)
> + return -ENOMEM;
[ ... ]
> + err = devm_of_mdiobus_register(dev, bus, node);
> + if (err)
> + return dev_err_probe(dev, err,
> + "Cannot register EMDIO bus\n");
[ ... ]
> +static int netc_init_all_ports(struct netc_switch *priv)
> +{
> + struct device *dev = priv->dev;
> + struct netc_port *np;
> + struct dsa_port *dp;
> + int err;
> +
> + priv->ports = devm_kcalloc(dev, priv->info->num_ports,
> + sizeof(struct netc_port *),
> + GFP_KERNEL);
> + if (!priv->ports)
> + return -ENOMEM;
[ ... ]
> + for (int i = 0; i < priv->info->num_ports; i++) {
> + np = devm_kzalloc(dev, sizeof(*np), GFP_KERNEL);
> + if (!np)
> + return -ENOMEM;
[ ... ]
> +static int netc_setup(struct dsa_switch *ds)
> +{
> + struct netc_switch *priv = ds->priv;
> + struct dsa_port *dp;
> + int err;
> +
> + err = netc_init_switch_id(priv);
> + if (err)
> + return err;
> +
> + err = netc_init_all_ports(priv);
The DSA subsystem can invoke the switch driver's .setup and .teardown
callbacks multiple times over the device's lifetime, such as when the
master netdevice is unbound and rebound.
Because devm_kcalloc(), devm_kzalloc(), and devm_of_mdiobus_register()
are tied to the PCI device's lifetime rather than the DSA switch tree,
these resources won't be freed when netc_teardown() is executed.
If the master interface is rebound and netc_setup() runs again, could
this cause memory leaks and a duplicate sysfs name collision when trying
to register the same MDIO bus?
[ ... ]
> +static void netc_switch_shutdown(struct pci_dev *pdev)
> +{
> + struct netc_switch *priv = pci_get_drvdata(pdev);
> +
> + if (!priv)
> + return;
> +
> + dsa_switch_shutdown(priv->ds);
> + pci_set_drvdata(pdev, NULL);
> +}
While dsa_switch_shutdown() brings the network interfaces down, does it
guarantee that all hardware DMA engines (such as the switch-wide NTMP
Command BD rings) are immediately halted?
If not, should this function call pci_clear_master() to prevent
the device from continuing pending DMA operations and potentially
corrupting memory during a kexec boot?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260513030454.1666570-1-wei.fang@nxp.com?part=10
next prev parent reply other threads:[~2026-05-14 5:57 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-13 3:04 [PATCH v7 net-next 00/15] Add preliminary NETC switch support for i.MX94 Wei Fang
2026-05-13 3:04 ` [PATCH v7 net-next 01/15] dt-bindings: net: dsa: update the description of 'dsa,member' property Wei Fang
2026-05-13 3:04 ` [PATCH v7 net-next 02/15] dt-bindings: net: dsa: add NETC switch Wei Fang
2026-05-13 3:04 ` [PATCH v7 net-next 03/15] net: enetc: add pre-boot initialization for i.MX94 switch Wei Fang
2026-05-13 3:04 ` [PATCH v7 net-next 04/15] net: enetc: add basic operations to the FDB table Wei Fang
2026-05-13 3:04 ` [PATCH v7 net-next 05/15] net: enetc: add support for the "Add" operation to VLAN filter table Wei Fang
2026-05-13 3:04 ` [PATCH v7 net-next 06/15] net: enetc: add support for the "Update" operation to buffer pool table Wei Fang
2026-05-13 3:04 ` [PATCH v7 net-next 07/15] net: enetc: add support for "Add" and "Delete" operations to IPFT Wei Fang
2026-05-13 3:04 ` [PATCH v7 net-next 08/15] net: enetc: add multiple command BD rings support Wei Fang
2026-05-13 3:04 ` [PATCH v7 net-next 09/15] net: dsa: add NETC switch tag support Wei Fang
2026-05-14 5:22 ` sashiko-bot
2026-05-13 3:04 ` [PATCH v7 net-next 10/15] net: dsa: netc: introduce NXP NETC switch driver for i.MX94 Wei Fang
2026-05-14 5:57 ` sashiko-bot [this message]
2026-05-13 3:04 ` [PATCH v7 net-next 11/15] net: dsa: netc: add phylink MAC operations Wei Fang
2026-05-13 3:04 ` [PATCH v7 net-next 12/15] net: dsa: netc: add FDB, STP, MTU, port setup and host flooding support Wei Fang
2026-05-14 8:21 ` sashiko-bot
2026-05-13 3:04 ` [PATCH v7 net-next 13/15] net: dsa: netc: initialize buffer pool table and implement flow-control Wei Fang
2026-05-14 8:51 ` sashiko-bot
2026-05-13 3:04 ` [PATCH v7 net-next 14/15] net: dsa: netc: add support for the standardized counters Wei Fang
2026-05-13 3:04 ` [PATCH v7 net-next 15/15] net: dsa: netc: add support for ethtool private statistics Wei Fang
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=20260514055715.A004FC2BCB7@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=imx@lists.linux.dev \
--cc=krzk+dt@kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wei.fang@nxp.com \
/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