ARM Sunxi Platform Development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Arun Iyengar" <aiyengar1990@gmail.com>
Cc: linux-sunxi@lists.linux.dev
Subject: Re: [PATCH net-next v4 3/5] net: stmmac: Balance runtime PM when the probe fails
Date: Sat, 21 Nov 2026 10:46:00 +0000	[thread overview]
Message-ID: <sashiko-outbox-226953@kernel.org> (raw)
In-Reply-To: <20261120-sun8i-emac-mux-uaf-v4-3-57eba8915f25@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] net: stmmac: unbalanced pm_runtime_disable() in
  __stmmac_dvr_probe()
- [Low] net: stmmac: missing Fixes trailer for probe runtime PM leak
--

commit 150d8ab7f1c2f574c3442bec9dafca1bba988cdd
Author: Arun Iyengar <aiyengar1990@gmail.com>

> net: stmmac: Balance runtime PM when the probe fails
>
> __stmmac_dvr_probe() enables runtime PM and takes a usage count before
> it registers the MDIO bus, but its error path undoes neither. After a
> failed or deferred probe the device never runtime-suspends.
>
> Undo both, as stmmac_dvr_remove() does.
>
> Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>

[Severity: Low]
Should this bug fix include a Fixes tag for the commit that added runtime
PM handling to probe without cleaning it up on the error path?

  Fixes: 5ec55823438e ("net: stmmac: add clocks management for gmac driver")

> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index f256244ce0d11..4ebf4b6253743 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -8407,6 +8407,8 @@ static int __stmmac_dvr_probe(struct device *device,
>  error_pcs_setup:
>  	stmmac_mdio_unregister(ndev);
>  error_mdio_register:
> +	pm_runtime_disable(device);
> +	pm_runtime_put_noidle(device);
>  	stmmac_napi_del(ndev);
>  error_hw_init:
>  	destroy_workqueue(priv->wq);

[Severity: Medium]
Can calling pm_runtime_disable(device) unconditionally here leave runtime
PM unbalanced on buses that enable runtime PM before probing?

Earlier in __stmmac_dvr_probe(), pm_runtime_enable() is only called when
runtime PM is not already enabled:

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:__stmmac_dvr_probe() {
    ...
	pm_runtime_get_noresume(device);
	pm_runtime_set_active(device);
	if (!pm_runtime_enabled(device))
		pm_runtime_enable(device);
    ...
}

For PCI stmmac devices, pci_bus_add_device() enables runtime PM before the
driver probes, so __stmmac_dvr_probe() skips pm_runtime_enable().  If
stmmac_mdio_register() or a later step fails or defers, this error path
still calls pm_runtime_disable(device), incrementing disable_depth from 0
to 1.  When probe unwind runs pm_runtime_reinit(), it sees runtime PM
disabled and forces the device to RPM_SUSPENDED while still in D0,
decrementing the parent bridge's active child count and causing a
subsequent re-probe's pm_runtime_get_sync() in local_pci_probe() to fail
with -EACCES.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120-sun8i-emac-mux-uaf-v4-0-57eba8915f25@gmail.com?part=3

  reply	other threads:[~2026-11-21 10:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 10:45 [PATCH net-next v4 0/5] net: stmmac: dwmac-sun8i: Fix the EPHY and MDIO mux ordering Arun Iyengar via B4 Relay
2026-11-20 10:45 ` [PATCH net-next v4 1/5] net: stmmac: dwmac-sun8i: Put the EPHY clock and reset after the MAC Arun Iyengar via B4 Relay
2026-11-20 10:45 ` [PATCH net-next v4 2/5] net: stmmac: dwmac-sun8i: Get the EPHY clock and reset before the MAC probe Arun Iyengar via B4 Relay
2026-11-20 10:45 ` [PATCH net-next v4 3/5] net: stmmac: Balance runtime PM when the probe fails Arun Iyengar via B4 Relay
2026-11-21 10:46   ` sashiko-bot [this message]
2026-11-20 10:45 ` [PATCH net-next v4 4/5] net: stmmac: Add MDIO init and exit platform hooks Arun Iyengar via B4 Relay
2026-11-20 10:45 ` [PATCH net-next v4 5/5] net: stmmac: dwmac-sun8i: Register the MDIO mux in the MDIO setup Arun Iyengar via B4 Relay

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=sashiko-outbox-226953@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=aiyengar1990@gmail.com \
    --cc=linux-sunxi@lists.linux.dev \
    --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