lan743x: Fix RX Kernel Panic
authorBryan Whitehead <Bryan.Whitehead@microchip.com>
Mon, 11 Mar 2019 17:39:39 +0000 (13:39 -0400)
committerDavid S. Miller <davem@davemloft.net>
Mon, 11 Mar 2019 19:20:20 +0000 (12:20 -0700)
commitdd9d9f5907bb475f8b1796c47d4ecc7fb9b72136
treed06f79fa359b2d3e3aadf5e9a037661eda9db333
parentfe543b2f174f34a7a751aa08b334fe6b105c4569
lan743x: Fix RX Kernel Panic

It has been noticed that running the speed test at
www.speedtest.net occasionally causes a kernel panic.

Investigation revealed that under this test RX buffer allocation
sometimes fails and returns NULL. But the lan743x driver did
not handle this case.

This patch fixes this issue by attempting to allocate a buffer
before sending the new rx packet to the OS. If the allocation
fails then the new rx packet is dropped and the existing buffer
is reused in the DMA ring.

Updates for v2:
    Additional 2 locations where allocation was not checked,
        has been changed to reuse existing buffer.

Fixes: 23f0703c125b ("lan743x: Add main source files for new lan743x driver")
Signed-off-by: Bryan Whitehead <Bryan.Whitehead@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/microchip/lan743x_main.c