Commit b4f4c368 authored by Sergei Shtylyov's avatar Sergei Shtylyov Committed by Ben Hutchings

sh_eth: fix NULL pointer dereference in sh_eth_ring_format()

[ Upstream commit c1b7fca6 ]

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: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: default avatarSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 2b432a04
...@@ -1162,6 +1162,7 @@ static void sh_eth_ring_format(struct net_device *ndev) ...@@ -1162,6 +1162,7 @@ static void sh_eth_ring_format(struct net_device *ndev)
mdp->dirty_rx = (u32) (i - mdp->num_rx_ring); mdp->dirty_rx = (u32) (i - mdp->num_rx_ring);
/* Mark the last entry as wrapping the ring. */ /* Mark the last entry as wrapping the ring. */
if (rxdesc)
rxdesc->status |= cpu_to_edmac(mdp, RD_RDEL); rxdesc->status |= cpu_to_edmac(mdp, RD_RDEL);
memset(mdp->tx_ring, 0, tx_ringsize); memset(mdp->tx_ring, 0, tx_ringsize);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment