From: sashiko-bot@kernel.org
To: "Markus Stockhausen" <markus.stockhausen@gmx.de>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH net-next v8 4/9] net: mdio: realtek-rtl9300: extend controller structure lifetime
Date: Tue, 28 Jul 2026 19:16:43 +0000 [thread overview]
Message-ID: <20260728191643.956721F00A3E@smtp.kernel.org> (raw)
In-Reply-To: <20260727191559.19617-5-markus.stockhausen@gmx.de>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Ineffective Fix / Unresolved Use-After-Free
--
--- Patch [4]: [PATCH net-next v8 4/9] net: mdio: realtek-rtl9300: extend controller structure lifetime ---
commit b6df87c0a19bdf7cb3946cca13544583a9dac7fd
Author: Markus Stockhausen <markus.stockhausen@gmx.de>
net: mdio: realtek-rtl9300: extend controller structure lifetime
This commit attempts to use a kref counter for the controller private data
to decouple its lifetime from the platform device and tie it to the MDIO
buses, aiming to prevent a use-after-free during teardown.
> diff --git a/drivers/net/mdio/mdio-realtek-rtl9300.c b/drivers/net/mdio/mdio-realtek-rtl9300.c
> index 3dee5bff41349..9529f877248ba 100644
> --- a/drivers/net/mdio/mdio-realtek-rtl9300.c
> +++ b/drivers/net/mdio/mdio-realtek-rtl9300.c
[ ... ]
> @@ -617,6 +634,11 @@ static int otto_emdio_probe_one(struct device *dev, struct otto_emdio_priv *priv
>
> snprintf(bus->id, MII_BUS_ID_SIZE, "%s-%d", dev_name(dev), mdio_bus);
>
> + kref_get(&priv->kref);
> + err = devm_add_action_or_reset(dev, otto_emdio_cleanup_bus, priv);
> + if (err)
> + return dev_err_probe(dev, err, "cannot register cleanup action\n");
> +
[Severity: High]
This is a pre-existing issue, but does this approach actually decouple the
lifetime from the platform device?
In otto_emdio_probe_one(), registering the cleanup action against the
platform device (dev) via devm_add_action_or_reset() means
devres_release_all() will still execute otto_emdio_cleanup_bus()
synchronously during the platform device unbind phase.
Won't this drop the kref to 0 and free the priv structure at the exact same
time as the old devm_kzalloc() teardown would have, regardless of whether
the mii_bus objects are kept alive by external references?
If the mii_bus objects outlive the platform device unbind, could accessing
bus operations still dereference the freed priv pointer?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260727191559.19617-1-markus.stockhausen@gmx.de?part=4
next prev parent reply other threads:[~2026-07-28 19:16 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-27 19:15 [PATCH net-next v8 0/9] net: mdio: realtek-rtl9300: Add RTL83xx support Markus Stockhausen
2026-07-27 19:15 ` [PATCH net-next v8 1/9] dt-bindings: net: realtek,rtl9301-mdio: Add RTL83xx series Markus Stockhausen
2026-07-27 19:15 ` [PATCH net-next v8 2/9] net: mdio: realtek-rtl9300: Add polling documentation Markus Stockhausen
2026-07-27 19:15 ` [PATCH net-next v8 3/9] net: phy: add (*notify_phy_attach/detach)() hooks to struct mii_bus Markus Stockhausen
2026-07-28 19:16 ` sashiko-bot
2026-07-27 19:15 ` [PATCH net-next v8 4/9] net: mdio: realtek-rtl9300: extend controller structure lifetime Markus Stockhausen
2026-07-28 19:16 ` sashiko-bot [this message]
2026-07-27 19:15 ` [PATCH net-next v8 5/9] net: mdio: realtek-rtl9300: Configure hardware polling during probing Markus Stockhausen
2026-07-28 19:16 ` sashiko-bot
2026-07-27 19:15 ` [PATCH net-next v8 6/9] net: mdio: realtek-rtl9300: Add page tracking Markus Stockhausen
2026-07-28 19:16 ` sashiko-bot
2026-07-27 19:15 ` [PATCH net-next v8 7/9] net: mdio: realtek-rtl9300: Increase MDIO timeout Markus Stockhausen
2026-07-27 19:15 ` [PATCH net-next v8 8/9] net: mdio: realtek-rtl9300: Add support for RTL838x Markus Stockhausen
2026-07-28 19:16 ` sashiko-bot
2026-07-27 19:15 ` [PATCH net-next v8 9/9] net: mdio: realtek-rtl9300: Add support for RTL839x 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=20260728191643.956721F00A3E@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox