diff options
author | Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> | 2016-03-08 01:36:28 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-03-10 16:06:49 -0500 |
commit | c1b7fca65070bfadca94dd53a4e6b71cd4f69715 (patch) | |
tree | 7ff171853047b435e711ac14a69f8bd31167dec1 /drivers/net/ethernet/renesas | |
parent | f720d0caa0af2c33ad15310974c7320345ab4468 (diff) | |
download | linux-c1b7fca65070bfadca94dd53a4e6b71cd4f69715.tar.gz linux-c1b7fca65070bfadca94dd53a4e6b71cd4f69715.tar.bz2 linux-c1b7fca65070bfadca94dd53a4e6b71cd4f69715.zip |
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 <wsa+renesas@sang-engineering.com>
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/renesas')
-rw-r--r-- | drivers/net/ethernet/renesas/sh_eth.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index 9c6448915b65..6fb75a1d68b9 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -1154,7 +1154,8 @@ static void sh_eth_ring_format(struct net_device *ndev) mdp->dirty_rx = (u32) (i - mdp->num_rx_ring); /* Mark the last entry as wrapping the ring. */ - rxdesc->status |= cpu_to_le32(RD_RDLE); + if (rxdesc) + rxdesc->status |= cpu_to_le32(RD_RDLE); memset(mdp->tx_ring, 0, tx_ringsize); |