diff mbox

r8169 skb leak

Message ID 20090313211008.GA14796@redhat.com
State Superseded, archived
Delegated to: David Miller
Headers show

Commit Message

Dave Jones March 13, 2009, 9:10 p.m. UTC
r8169 seems to have the same problem that the via-velocity did with skb padding.
Found by code-inspection only, no hardware to test.

Signed-off-by: Dave Jones <davej@redhat.com>

Comments

Francois Romieu March 13, 2009, 10:26 p.m. UTC | #1
Dave Jones <davej@redhat.com> :
> r8169 seems to have the same problem that the via-velocity did with skb padding.
> Found by code-inspection only, no hardware to test.

Davem, can you defer this one until now + 24h ?

The hardware is supposed to auto-pad: I'd rather check it does with
a few adapters and remove this code altogether.
David Miller March 13, 2009, 10:33 p.m. UTC | #2
From: Francois Romieu <romieu@fr.zoreil.com>
Date: Fri, 13 Mar 2009 23:26:18 +0100

> Dave Jones <davej@redhat.com> :
> > r8169 seems to have the same problem that the via-velocity did with skb padding.
> > Found by code-inspection only, no hardware to test.
> 
> Davem, can you defer this one until now + 24h ?
> 
> The hardware is supposed to auto-pad: I'd rather check it does with
> a few adapters and remove this code altogether.

Sure.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index b347340..07b1de1 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -3145,7 +3145,9 @@  err_out:
 static void rtl8169_unmap_tx_skb(struct pci_dev *pdev, struct ring_info *tx_skb,
 				 struct TxDesc *desc)
 {
-	unsigned int len = tx_skb->len;
+	unsigned int len;
+
+	len = max_t(unsigned, tx_skb->len, ETH_ZLEN);
 
 	pci_unmap_single(pdev, le64_to_cpu(desc->addr), len, PCI_DMA_TODEVICE);
 	desc->opts1 = 0x00;
@@ -3364,11 +3366,9 @@  static int rtl8169_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	} else {
 		len = skb->len;
 
-		if (unlikely(len < ETH_ZLEN)) {
-			if (skb_padto(skb, ETH_ZLEN))
-				goto err_update_stats;
-			len = ETH_ZLEN;
-		}
+		if (skb_padto(skb, ETH_ZLEN))
+			goto err_update_stats;
+		len = max_t(unsigned, skb->len, ETH_ZLEN);
 
 		opts1 |= FirstFrag | LastFrag;
 		tp->tx_skb[entry].skb = skb;