From: "Théo Lebrun" <theo.lebrun@bootlin.com>
To: "Wentao Liang" <vulab@iscas.ac.cn>, <andrew+netdev@lunn.ch>
Cc: <conor.dooley@microchip.com>, <davem@davemloft.net>,
<edumazet@google.com>, <kuba@kernel.org>,
<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
<o.rempel@pengutronix.de>, <pabeni@redhat.com>,
<stable@vger.kernel.org>
Subject: Re: [PATCH] net: macb: Fix mdio_np reference leak in macb_mii_init()
Date: Thu, 17 Sep 2026 13:59:46 +0200 [thread overview]
Message-ID: <DLHKP3SF683I.Q29HH06Z2MCY@bootlin.com> (raw)
In-Reply-To: <20260917105223.2147724-1-vulab@iscas.ac.cn>
Hello Wentao,
On Thu Sep 17, 2026 at 12:52 PM CEST, Wentao Liang wrote:
> of_get_child_by_name() returns a device node with an elevated reference
> count. macb_mii_init() drops it on the error paths via err_out, but the
> success path returns 0 without calling of_node_put(), leaking a
> reference to the "mdio" child node on every successful probe.
>
> Release the reference before returning on the success path.
>
> Fixes: 8a6631f1cece ("net: macb: avoid redundant lookup for "mdio" child node in MDIO setup")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
> drivers/net/ethernet/cadence/macb_main.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index a12aa21244e8..0c4775d51263 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -1164,6 +1164,8 @@ static int macb_mii_init(struct macb *bp)
> if (err)
> goto err_out_unregister_bus;
>
> + of_node_put(mdio_np);
> +
> return 0;
>
> err_out_unregister_bus:
This patch has been sent by Nicolai last week. It has been applied &
merged into net/main then torvalds/master.
https://lore.kernel.org/netdev/20260907210856.1673589-3-nb@tipi-net.de/
⟩ git log --oneline --grep='child node reference on success' \
torvalds/master drivers/net/ethernet/cadence/
382a373d9ea7a net: macb: put the "mdio" child node reference on success
Thanks,
--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
prev parent reply other threads:[~2026-09-17 12:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 10:52 Wentao Liang
2026-09-17 11:59 ` Théo Lebrun [this message]
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=DLHKP3SF683I.Q29HH06Z2MCY@bootlin.com \
--to=theo.lebrun@bootlin.com \
--cc=andrew+netdev@lunn.ch \
--cc=conor.dooley@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
--cc=vulab@iscas.ac.cn \
/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
all inboxes | Powered by JetHome®