* [PATCH net] net: phylink: correctly validate returned PCS in phylink_inband_caps
@ 2026-08-17 21:30 Christian Marangi
2026-08-20 21:20 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Christian Marangi @ 2026-08-17 21:30 UTC (permalink / raw)
To: Russell King, Andrew Lunn, Heiner Kallweit, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Russell King (Oracle),
netdev, linux-kernel
Cc: Christian Marangi, stable
In phylink_inband_caps(), the PCS returned by mac_select_pcs is only
checked if NULL but mac_select_pcs can also return an error pointer.
This can cause a kernel panic as phylink_pcs_inband_caps() only checks
if passed PCS is not NULL and directly dereference ops from the phylink_pcs
struct.
Use the IS_ERR_OR_NULL macro to address both case where the returned
PCS can be NULL or an error pointer and prevent a kernel panic.
Cc: stable@vger.kernel.org
Fixes: df874f9e52c3 ("net: phylink: add pcs_inband_caps() method")
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
drivers/net/phy/phylink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 5b8e956902fb..3ec3bb439109 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -964,7 +964,7 @@ static unsigned int phylink_inband_caps(struct phylink *pl,
return 0;
pcs = pl->mac_ops->mac_select_pcs(pl->config, interface);
- if (!pcs)
+ if (IS_ERR_OR_NULL(pcs))
return 0;
return phylink_pcs_inband_caps(pcs, interface);
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] net: phylink: correctly validate returned PCS in phylink_inband_caps
2026-08-17 21:30 [PATCH net] net: phylink: correctly validate returned PCS in phylink_inband_caps Christian Marangi
@ 2026-08-20 21:20 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-08-20 21:20 UTC (permalink / raw)
To: Christian Marangi
Cc: linux, andrew, hkallweit1, davem, edumazet, kuba, pabeni,
rmk+kernel, netdev, linux-kernel, stable
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 17 Aug 2026 23:30:03 +0200 you wrote:
> In phylink_inband_caps(), the PCS returned by mac_select_pcs is only
> checked if NULL but mac_select_pcs can also return an error pointer.
>
> This can cause a kernel panic as phylink_pcs_inband_caps() only checks
> if passed PCS is not NULL and directly dereference ops from the phylink_pcs
> struct.
>
> [...]
Here is the summary with links:
- [net] net: phylink: correctly validate returned PCS in phylink_inband_caps
https://git.kernel.org/netdev/net/c/f2849b1fd059
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] 2+ messages in thread
end of thread, other threads:[~2026-08-20 21:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-17 21:30 [PATCH net] net: phylink: correctly validate returned PCS in phylink_inband_caps Christian Marangi
2026-08-20 21:20 ` 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