* [PATCH net] net: sxgbe: fix potential NULL dereference in sxgbe_rx()
@ 2025-11-21 12:38 Alexey Kodanev
2025-11-25 15:15 ` Simon Horman
2025-11-26 3:20 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Alexey Kodanev @ 2025-11-21 12:38 UTC (permalink / raw)
To: netdev
Cc: Byungho An, Andrew Lunn, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Girish K S, Siva Reddy, Vipul Pandya,
Alexey Kodanev
Currently, when skb is null, the driver prints an error and then
dereferences skb on the next line.
To fix this, let's add a 'break' after the error message to switch
to sxgbe_rx_refill(), which is similar to the approach taken by the
other drivers in this particular case, e.g. calxeda with xgmac_rx().
Found during a code review.
Fixes: 1edb9ca69e8a ("net: sxgbe: add basic framework for Samsung 10Gb ethernet driver")
Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
---
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
index 75bad561b352..849c5a6c2af1 100644
--- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
+++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
@@ -1521,8 +1521,10 @@ static int sxgbe_rx(struct sxgbe_priv_data *priv, int limit)
skb = priv->rxq[qnum]->rx_skbuff[entry];
- if (unlikely(!skb))
+ if (unlikely(!skb)) {
netdev_err(priv->dev, "rx descriptor is not consistent\n");
+ break;
+ }
prefetch(skb->data - NET_IP_ALIGN);
priv->rxq[qnum]->rx_skbuff[entry] = NULL;
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: sxgbe: fix potential NULL dereference in sxgbe_rx()
2025-11-21 12:38 [PATCH net] net: sxgbe: fix potential NULL dereference in sxgbe_rx() Alexey Kodanev
@ 2025-11-25 15:15 ` Simon Horman
2025-11-26 3:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2025-11-25 15:15 UTC (permalink / raw)
To: Alexey Kodanev
Cc: netdev, Byungho An, Andrew Lunn, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Girish K S, Siva Reddy, Vipul Pandya
On Fri, Nov 21, 2025 at 12:38:34PM +0000, Alexey Kodanev wrote:
> Currently, when skb is null, the driver prints an error and then
> dereferences skb on the next line.
>
> To fix this, let's add a 'break' after the error message to switch
> to sxgbe_rx_refill(), which is similar to the approach taken by the
> other drivers in this particular case, e.g. calxeda with xgmac_rx().
>
> Found during a code review.
>
> Fixes: 1edb9ca69e8a ("net: sxgbe: add basic framework for Samsung 10Gb ethernet driver")
> Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
Thanks Alexey,
I think this is a case where it is hard to know the true effects
without running the system. But I'm assuming that we aren't in
a position to do so. So instead we need to try to reason at
the code level.
From that perspective I do see that:
1. Without this change there will be a NULL pointer dereference *boob*
2. It seems that the refill logic should work with the proposed solution
So, I do expect this helps.
And I do think it can be accepted without hw testing.
But I do have a lower confidence level than I would if there
was hw testing.
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: sxgbe: fix potential NULL dereference in sxgbe_rx()
2025-11-21 12:38 [PATCH net] net: sxgbe: fix potential NULL dereference in sxgbe_rx() Alexey Kodanev
2025-11-25 15:15 ` Simon Horman
@ 2025-11-26 3:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-11-26 3:20 UTC (permalink / raw)
To: Alexey Kodanev
Cc: netdev, bh74.an, andrew+netdev, davem, edumazet, kuba, pabeni,
ks.giri, siva.kallam, vipul.pandya
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Fri, 21 Nov 2025 12:38:34 +0000 you wrote:
> Currently, when skb is null, the driver prints an error and then
> dereferences skb on the next line.
>
> To fix this, let's add a 'break' after the error message to switch
> to sxgbe_rx_refill(), which is similar to the approach taken by the
> other drivers in this particular case, e.g. calxeda with xgmac_rx().
>
> [...]
Here is the summary with links:
- [net] net: sxgbe: fix potential NULL dereference in sxgbe_rx()
https://git.kernel.org/netdev/net/c/f5bce28f6b91
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-11-26 3:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-21 12:38 [PATCH net] net: sxgbe: fix potential NULL dereference in sxgbe_rx() Alexey Kodanev
2025-11-25 15:15 ` Simon Horman
2025-11-26 3: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;
as well as URLs for NNTP newsgroup(s).