diff options
author | Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> | 2016-03-08 01:36:28 +0300 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2016-05-01 00:05:27 +0200 |
commit | 6e0784b636cc75d81c870fde19cfbd7a58267edf (patch) | |
tree | 41bc6f104f1064bca367ac75db2004e46717eb09 | |
parent | 0954b59d9f4b2dcc59f28d1f64c3a21062a64372 (diff) | |
download | linux-stable-6e0784b636cc75d81c870fde19cfbd7a58267edf.tar.gz linux-stable-6e0784b636cc75d81c870fde19cfbd7a58267edf.tar.bz2 linux-stable-6e0784b636cc75d81c870fde19cfbd7a58267edf.zip |
sh_eth: fix NULL pointer dereference in sh_eth_ring_format()
[ Upstream commit c1b7fca65070bfadca94dd53a4e6b71cd4f69715 ]
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>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-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 9842fd92c483..85170f105568 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -681,7 +681,8 @@ static void sh_eth_ring_format(struct net_device *ndev) mdp->dirty_rx = (u32) (i - RX_RING_SIZE); /* Mark the last entry as wrapping the ring. */ - rxdesc->status |= cpu_to_edmac(mdp, RD_RDEL); + if (rxdesc) + rxdesc->status |= cpu_to_edmac(mdp, RD_RDEL); memset(mdp->tx_ring, 0, tx_ringsize); |