From: sashiko-bot@kernel.org
To: "Markus Stockhausen" <markus.stockhausen@gmx.de>
Cc: conor+dt@kernel.org, robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH net-next v10 05/10] net: mdio: realtek-rtl9300: Configure hardware polling during probing
Date: Sat, 01 Aug 2026 06:14:50 +0000 [thread overview]
Message-ID: <20260801061451.65C971F00AC4@smtp.kernel.org> (raw)
In-Reply-To: <20260731061400.78301-6-markus.stockhausen@gmx.de>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Module unload race / Use-After-Free due to devres action attached to class device
--
--- Patch [5]: [PATCH net-next v10 05/10] net: mdio: realtek-rtl9300: Configure hardware polling during probing ---
commit 46ab2c1bebbed4638cc44b5a4c270ec37988afc7
Author: Markus Stockhausen <markus.stockhausen@gmx.de>
net: mdio: realtek-rtl9300: Configure hardware polling during probing
This patch allows the polling of Realtek Otto switches to be enabled or
disabled during PHY configuration. This prevents hardware polling from
interfering with complex configuration sequences or firmware loading. Polling
is kept in a consistent state by disabling it initially and toggling it
during PHY attach and detach.
Link: https://github.com/openwrt/openwrt/blob/main/target/linux/realtek/files-6.18/drivers/net/mdio/mdio-realtek-otto.c#L818
Link: https://lore.kernel.org/netdev/680696024a8648535ce6dee771fe4de67802e0e8.1769053496.git.daniel@makrotopia.org/
> diff --git a/drivers/net/mdio/mdio-realtek-rtl9300.c b/drivers/net/mdio/mdio-realtek-rtl9300.c
> index 7dcfb72ed8188..f1f15ad23dd3d 100644
> --- a/drivers/net/mdio/mdio-realtek-rtl9300.c
> +++ b/drivers/net/mdio/mdio-realtek-rtl9300.c
[ ... ]
> @@ -628,6 +663,9 @@ static int otto_emdio_probe_one(struct device *dev, struct otto_emdio_priv *priv
> bus->write = otto_emdio_write_c22;
> }
> bus->parent = dev;
> + bus->notify_phy_attach = otto_emdio_notify_phy_attach;
> + bus->notify_phy_detach = otto_emdio_notify_phy_detach;
> +
> chan = bus->priv;
> chan->mdio_bus = mdio_bus;
> chan->priv = priv;
[Severity: High]
While reviewing these changes to otto_emdio_probe_one(), I noticed a
potential resource management issue further down in the same function:
drivers/net/mdio/mdio-realtek-rtl9300.c:otto_emdio_probe_one() {
...
kref_get(&priv->kref);
err = devm_add_action_or_reset(&bus->dev, otto_emdio_cleanup_bus, priv);
...
}
Could this sequence lead to a module text use-after-free on unload?
Because bus->dev is a class device, a local user can extend its lifetime
indefinitely by keeping its sysfs file open. If an administrator unloads
the module, the module unloads successfully.
When the user later closes the sysfs file, won't the release of bus->dev
trigger the devres action and attempt to execute otto_emdio_cleanup_bus()
after the module code has already been unmapped?
Should this cleanup action be attached to the parent platform dev instead
of the class device?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260731061400.78301-1-markus.stockhausen@gmx.de?part=5
next prev parent reply other threads:[~2026-08-01 6:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 6:13 [PATCH net-next v10 00/10] net: mdio: realtek-rtl9300: Add RTL83xx support Markus Stockhausen
2026-07-31 6:13 ` [PATCH net-next v10 01/10] dt-bindings: net: realtek,rtl9301-mdio: Add RTL83xx series Markus Stockhausen
2026-07-31 6:13 ` [PATCH net-next v10 02/10] net: mdio: realtek-rtl9300: Add polling documentation Markus Stockhausen
2026-07-31 6:13 ` [PATCH net-next v10 03/10] net: phy: add (*notify_phy_attach/detach)() hooks to struct mii_bus Markus Stockhausen
2026-08-01 6:14 ` sashiko-bot
2026-07-31 6:13 ` [PATCH net-next v10 04/10] net: mdio: realtek-rtl9300: extend controller structure lifetime Markus Stockhausen
2026-08-01 6:14 ` sashiko-bot
2026-07-31 6:13 ` [PATCH net-next v10 05/10] net: mdio: realtek-rtl9300: Configure hardware polling during probing Markus Stockhausen
2026-08-01 6:14 ` sashiko-bot [this message]
2026-07-31 6:13 ` [PATCH net-next v10 06/10] net: mdio: realtek-rtl9300: Add page tracking Markus Stockhausen
2026-07-31 6:13 ` [PATCH net-next v10 07/10] net: mdio: realtek-rtl9300: Increase MDIO timeout Markus Stockhausen
2026-07-31 6:13 ` [PATCH net-next v10 08/10] net: mdio: realtek-rtl9300: Add support for RTL838x Markus Stockhausen
2026-07-31 6:13 ` [PATCH net-next v10 09/10] net: mdio: realtek-rtl9300: Add support for RTL839x Markus Stockhausen
2026-07-31 6:14 ` [PATCH net-next v10 10/10] net: mdio: reword MDIO_REALTEK_RTL9300 Kconfig Markus Stockhausen
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=20260801061451.65C971F00AC4@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=markus.stockhausen@gmx.de \
--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.