net: sxgbe: fix potential NULL dereference in sxgbe_rx()
Subsystems (3)
PATCH 1/1 net: sxgbe: fix potential NULL dereference in sxgbe_rx()
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.
--- drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c +3 -1
@@ -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 ;
Signature · 1 line
2.25.1
Quoted 11 lines · 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 withxgmac_rx().Found during a code review.
Fixes 1edb9ca69e8a ("net: sxgbe: add basic framework for Samsung 10Gb ethernet driver")Signed-off-by Alexey Kodanev <[email protected]>
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.
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 8 lines · 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 withxgmac_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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html