* [PATCH net] net: phylink: move PHY interrupt request to non-fail path
@ 2025-09-01 11:52 Russell King (Oracle)
2025-09-03 0:56 ` Andrew Lunn
2025-09-04 0:00 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Russell King (Oracle) @ 2025-09-01 11:52 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, netdev,
Paolo Abeni
The blamed commit added code which could return an error after we
requested the PHY interrupt. When we return an error, the caller
will call phy_detach() which fails to free the interrupt.
Rearrange the code such that failing operations happen before the
interrupt is requested, thereby allowing phy_detach() to be used.
Note that replacing phy_detach() with phy_disconnect() in these
paths could lead to freeing an interrupt which was never requested.
Fixes: 1942b1c6f687 ("net: phylink: make configuring clock-stop dependent on MAC support")
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
drivers/net/phy/phylink.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index c7f867b361dd..9a39478d9841 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -2132,9 +2132,6 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy,
__ETHTOOL_LINK_MODE_MASK_NBITS, pl->supported,
__ETHTOOL_LINK_MODE_MASK_NBITS, phy->advertising);
- if (phy_interrupt_is_valid(phy))
- phy_request_interrupt(phy);
-
if (pl->config->mac_managed_pm)
phy->mac_managed_pm = true;
@@ -2151,6 +2148,9 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy,
ret = 0;
}
+ if (ret == 0 && phy_interrupt_is_valid(phy))
+ phy_request_interrupt(phy);
+
return ret;
}
--
2.47.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: phylink: move PHY interrupt request to non-fail path
2025-09-01 11:52 [PATCH net] net: phylink: move PHY interrupt request to non-fail path Russell King (Oracle)
@ 2025-09-03 0:56 ` Andrew Lunn
2025-09-04 0:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2025-09-03 0:56 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Heiner Kallweit, David S. Miller, Eric Dumazet, Jakub Kicinski,
netdev, Paolo Abeni
> + if (ret == 0 && phy_interrupt_is_valid(phy))
> + phy_request_interrupt(phy);
> +
ret == 0 is a bit of an anti pattern, but O.K:
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: phylink: move PHY interrupt request to non-fail path
2025-09-01 11:52 [PATCH net] net: phylink: move PHY interrupt request to non-fail path Russell King (Oracle)
2025-09-03 0:56 ` Andrew Lunn
@ 2025-09-04 0:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-09-04 0:00 UTC (permalink / raw)
To: Russell King; +Cc: andrew, hkallweit1, davem, edumazet, kuba, netdev, pabeni
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 01 Sep 2025 12:52:56 +0100 you wrote:
> The blamed commit added code which could return an error after we
> requested the PHY interrupt. When we return an error, the caller
> will call phy_detach() which fails to free the interrupt.
>
> Rearrange the code such that failing operations happen before the
> interrupt is requested, thereby allowing phy_detach() to be used.
>
> [...]
Here is the summary with links:
- [net] net: phylink: move PHY interrupt request to non-fail path
https://git.kernel.org/netdev/net/c/3bc32fd9db47
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-04 0:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-01 11:52 [PATCH net] net: phylink: move PHY interrupt request to non-fail path Russell King (Oracle)
2025-09-03 0:56 ` Andrew Lunn
2025-09-04 0:00 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).