Skip to contentSkip to conversation

sky2: Fix crash inside sky2_rx_clean

PATCH Applied Mirko Lindner 3 participants 3 messages Nov 26, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sky2: Fix crash inside sky2_rx_clean

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.

---
 drivers/net/ethernet/marvell/sky2.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/sky2.c +3 -1
index 53a1cc5..f8ab220 100644
@@ -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;
 
Signature · 1 line
2.1.3
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · On Wed, 26 Nov 2014 15:13:38 +0100 Mirko Lindner <[email protected]> wrote:

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:

Quoted 7 lines

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

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

This matches my earlier patch, but this one is just as good

maintainer Applied
#2 lore raw
In reply to Mirko Lindner

From: Mirko Lindner <[email protected]>
Date: Wed, 26 Nov 2014 15:13:38 +0100

Quoted 7 lines

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:

Quoted 7 lines

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

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

Applied, thanks.