]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
sky2: Fix crash inside sky2_rx_clean
authorMirko Lindner <mlindner@marvell.com>
Wed, 26 Nov 2014 14:13:38 +0000 (15:13 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 26 Nov 2014 20:16:40 +0000 (15:16 -0500)
If sky2->tx_le = pci_alloc_consistent() or sky2->tx_ring = kcalloc() in
sky2_alloc_buffers() fails, sky2->rx_ring = kcalloc() will never be called.
In this error case handling, sky2_rx_clean() is called from within
sky2_free_buffers().

In sky2_rx_clean() we find the following:

...
   memset(sky2->rx_le, 0, RX_LE_BYTES);
...

This results in a memset using a NULL pointer and will crash the system.

Signed-off-by: Mirko Lindner <mlindner@marvell.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/marvell/sky2.c

index 53a1cc52d49664c9ff12014e9bf660da32b7c97e..f8ab220bd72cc831eabdaf832b3ffbd5d059b5b2 100644 (file)
@@ -1361,7 +1361,9 @@ static void sky2_rx_clean(struct sky2_port *sky2)
 {
        unsigned i;
 
-       memset(sky2->rx_le, 0, RX_LE_BYTES);
+       if (sky2->rx_le)
+               memset(sky2->rx_le, 0, RX_LE_BYTES);
+
        for (i = 0; i < sky2->rx_pending; i++) {
                struct rx_ring_info *re = sky2->rx_ring + i;