RE: NULL Pointer Deference: NFS & Telnet

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Eric Dumazet
Date: Wednesday, May 26, 2010 - 1:48 pm

Le mercredi 26 mai 2010 à 15:19 -0500, Arce, Abraham a écrit :


Yes that makes sense, nr_frag is right after the packet (padded to L1
cache size)

But please do the correct allocation ?

Also, we dont need FCS ?

diff --git a/drivers/net/ks8851.c b/drivers/net/ks8851.c
index b4fb07a..05bd312 100644
--- a/drivers/net/ks8851.c
+++ b/drivers/net/ks8851.c
@@ -503,8 +503,9 @@ static void ks8851_rx_pkts(struct ks8851_net *ks)
 		ks8851_wrreg16(ks, KS_RXQCR,
 			       ks->rc_rxqcr | RXQCR_SDA | RXQCR_ADRFE);
 
-		if (rxlen > 0) {
-			skb = netdev_alloc_skb(ks->netdev, rxlen + 2 + 8);
+		if (rxlen > 4) {
+			rxlen -= 4;
+			skb = netdev_alloc_skb(ks->netdev, 2 + 8 + ALIGN(rxlen, 4));
 			if (!skb) {
 				/* todo - dump frame and move on */
 			}
@@ -513,7 +514,7 @@ static void ks8851_rx_pkts(struct ks8851_net *ks)
 			 * for the status header and 4 bytes of garbage */
 			skb_reserve(skb, 2 + 4 + 4);
 
-			rxpkt = skb_put(skb, rxlen - 4) - 8;
+			rxpkt = skb_put(skb, rxlen) - 8;
 
 			/* align the packet length to 4 bytes, and add 4 bytes
 			 * as we're getting the rx status header as well */
@@ -526,7 +527,7 @@ static void ks8851_rx_pkts(struct ks8851_net *ks)
 			netif_rx(skb);
 
 			ks->netdev->stats.rx_packets++;
-			ks->netdev->stats.rx_bytes += rxlen - 4;
+			ks->netdev->stats.rx_bytes += rxlen;
 		}
 
 		ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr);


--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
NULL Pointer Deference: NFS & Telnet, Arce, Abraham, (Mon May 24, 7:19 pm)
RE: NULL Pointer Deference: NFS & Telnet, Arce, Abraham, (Tue May 25, 6:48 pm)
Re: NULL Pointer Deference: NFS & Telnet, David Miller, (Tue May 25, 6:52 pm)
RE: NULL Pointer Deference: NFS & Telnet, Arce, Abraham, (Tue May 25, 7:02 pm)
RE: NULL Pointer Deference: NFS & Telnet, Eric Dumazet, (Tue May 25, 10:29 pm)
RE: NULL Pointer Deference: NFS & Telnet, Arce, Abraham, (Wed May 26, 1:19 pm)
RE: NULL Pointer Deference: NFS & Telnet, Eric Dumazet, (Wed May 26, 1:48 pm)
Re: NULL Pointer Deference: NFS & Telnet, David Miller, (Fri Jun 4, 4:15 pm)