]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
sh_eth: fix NULL pointer dereference in sh_eth_ring_format()
authorSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Mon, 7 Mar 2016 22:36:28 +0000 (01:36 +0300)
committerTim Gardner <tim.gardner@canonical.com>
Thu, 21 Apr 2016 13:20:27 +0000 (07:20 -0600)
BugLink: http://bugs.launchpad.net/bugs/1573034
[ 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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
drivers/net/ethernet/renesas/sh_eth.c

index 6a8fc0f341ff2528fdda1cb97f8e2934d99c5f14..a1702f4ac6ff53539df8be02209e9ec8f611f1c3 100644 (file)
@@ -1212,7 +1212,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_edmac(mdp, RD_RDLE);
+       if (rxdesc)
+               rxdesc->status |= cpu_to_edmac(mdp, RD_RDLE);
 
        memset(mdp->tx_ring, 0, tx_ringsize);