From: sashiko-bot@kernel.org
To: "Bartosz Golaszewski" <bartosz.golaszewski@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, Frank.Li@kernel.org, lee@kernel.org,
dri-devel@lists.freedesktop.org, imx@lists.linux.dev,
mfd@lists.linux.dev, conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH v3 14/20] net: mv643xx: use platform_device_set_of_node()
Date: Tue, 07 Jul 2026 13:25:01 +0000 [thread overview]
Message-ID: <20260707132502.42CEE1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260706-pdev-fwnode-ref-v3-14-1ff028e33779@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Pre-existing issues:
- [High] Dynamically allocated platform devices are leaked during driver removal due to missing `platform_device_put()`.
- [High] The static global `port_platdev` array is accessed without synchronization, leading to probe races and cross-device teardown corruption.
- [High] Missing `phy_disconnect()` on the error path of `mv643xx_eth_probe()`, leading to a use-after-free of the `net_device`.
--
commit 286e3bdd9b38ee5d56ee5ff7b8525f2effcb4c53
Author: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
net: mv643xx: use platform_device_set_of_node()
Ahead of reworking the reference counting logic for platform devices,
encapsulate the assignment of the OF node for dynamically allocated
platform devices with the provided helper.
> diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
> index 1881583be5ce2..9caa1e47c174c 100644
> --- a/drivers/net/ethernet/marvell/mv643xx_eth.c
> +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
[ ... ]
> @@ -2780,7 +2780,7 @@ static int mv643xx_eth_shared_of_add_port(struct platform_device *pdev,
> goto put_err;
> }
> ppdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
> - ppdev->dev.of_node = of_node_get(pnp);
> + platform_device_set_of_node(ppdev, pnp);
[Severity: High]
This isn't a bug introduced by this patch, but does this dynamically allocated
platform device leak during driver removal?
Earlier in mv643xx_eth_shared_of_add_port(), platform_device_alloc() sets the
initial reference count to 1. During removal, mv643xx_eth_shared_of_remove()
calls platform_device_del(), which removes the device from the hierarchy but
fails to drop the reference count.
Without a matching platform_device_put(), the device and its associated data
leak on unbind or probe failure.
[Severity: High]
This is also a pre-existing issue, but could this global port array logic
cause cross-device teardown corruption?
This function searches for a free slot in the global port_platdev array
without synchronization:
mv643xx_eth_shared_of_add_port() {
...
while (dev_num < 3 && port_platdev[dev_num])
dev_num++;
...
}
If controllers probe concurrently, they could race on this global state.
Additionally, if one controller is unbound via sysfs,
mv643xx_eth_shared_of_remove() unconditionally iterates over the global
array and deletes all ports:
mv643xx_eth_shared_of_remove() {
...
for (n = 0; n < 3; n++) {
if (!port_platdev[n])
continue;
platform_device_del(port_platdev[n]);
port_platdev[n] = NULL;
}
}
Wouldn't this destroy active network ports belonging to completely independent
controllers sharing the driver?
[Severity: High]
This is another pre-existing issue, but does the probe error path leave a
dangling pointer in the PHY subsystem?
In mv643xx_eth_probe(), the driver connects the PHY (which attaches it and
stores a pointer to the net_device in phydev->attached_dev). If a subsequent
operation in the probe fails, the error path frees the net_device but never
disconnects the PHY:
mv643xx_eth_probe() {
...
out:
if (!IS_ERR(mp->clk))
clk_disable_unprepare(mp->clk);
free_netdev(dev);
return err;
}
Can this lead to a use-after-free if the PHY device remains active and
is later accessed via sysfs or core PHY polling routines?
>
> ret = platform_device_add_resources(ppdev, &res, 1);
> if (ret)
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706-pdev-fwnode-ref-v3-0-1ff028e33779@oss.qualcomm.com?part=14
next prev parent reply other threads:[~2026-07-07 13:25 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 12:44 [PATCH v3 00/20] driver core: count references of the platform device's fwnode, not OF node Bartosz Golaszewski
2026-07-06 12:44 ` [PATCH v3 01/20] powerpc/powermac: fix OF node refcount Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 02/20] driver core: platform: provide platform_device_set_of_node() Bartosz Golaszewski
2026-07-06 14:39 ` Manuel Ebner
2026-07-06 14:48 ` Manuel Ebner
2026-07-06 15:49 ` Andy Shevchenko
2026-07-06 17:26 ` Mark Brown
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 03/20] driver core: platform: provide platform_device_set_fwnode() Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 04/20] driver core: platform: provide platform_device_set_of_node_from_dev() Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 05/20] driver core: update kerneldoc for platform_device_alloc() Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 06/20] of: platform: use platform_device_set_of_node() Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 07/20] powerpc/powermac: " Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 08/20] i2c: pxa-pci: " Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 09/20] iommu/fsl: " Bartosz Golaszewski
2026-07-06 14:51 ` Frank Li
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 10/20] net: bcmgenet: " Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 11/20] pmdomain: imx: " Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 12/20] mfd: tps6586: " Bartosz Golaszewski
2026-07-07 13:24 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 13/20] slimbus: qcom-ngd-ctrl: " Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 14/20] net: mv643xx: " Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot [this message]
2026-07-06 12:44 ` [PATCH v3 15/20] drm/xe/i2c: use platform_device_set_fwnode() Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 16/20] platform/surface: gpe: " Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 17/20] usb: chipidea: use platform_device_set_of_node_from_dev() Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 18/20] usb: musb: " Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 19/20] reset: rzg2l: " Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
2026-07-06 12:44 ` [PATCH v3 20/20] driver core: platform: count references to all kinds of firmware nodes Bartosz Golaszewski
2026-07-07 13:25 ` sashiko-bot
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=20260707132502.42CEE1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=bartosz.golaszewski@oss.qualcomm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=imx@lists.linux.dev \
--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