Skip to content

Commit c1b7fca

Browse files
Sergei Shtylyovdavem330
authored andcommitted
sh_eth: fix NULL pointer dereference in sh_eth_ring_format()
In a low memory situation, if netdev_alloc_skb() fails on a first RX ring loop iteration in sh_eth_ring_format(), 'rxdesc' is still NULL. Avoid kernel oops by adding the 'rxdesc' check after the loop. Reported-by: Wolfram Sang <[email protected]> Signed-off-by: Sergei Shtylyov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f720d0c commit c1b7fca

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/net/ethernet/renesas/sh_eth.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,8 @@ static void sh_eth_ring_format(struct net_device *ndev)
11541154
mdp->dirty_rx = (u32) (i - mdp->num_rx_ring);
11551155

11561156
/* Mark the last entry as wrapping the ring. */
1157-
rxdesc->status |= cpu_to_le32(RD_RDLE);
1157+
if (rxdesc)
1158+
rxdesc->status |= cpu_to_le32(RD_RDLE);
11581159

11591160
memset(mdp->tx_ring, 0, tx_ringsize);
11601161

0 commit comments

Comments
 (0)