From patchwork Tue Sep 7 21:43:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Arce, Abraham" X-Patchwork-Id: 64074 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 72831B6EEE for ; Wed, 8 Sep 2010 07:44:00 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751150Ab0IGVn4 (ORCPT ); Tue, 7 Sep 2010 17:43:56 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:45608 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751006Ab0IGVny convert rfc822-to-8bit (ORCPT ); Tue, 7 Sep 2010 17:43:54 -0400 Received: from dlep35.itg.ti.com ([157.170.170.118]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id o87LhpTK011181 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 7 Sep 2010 16:43:51 -0500 Received: from dlep26.itg.ti.com (localhost [127.0.0.1]) by dlep35.itg.ti.com (8.13.7/8.13.7) with ESMTP id o87LhpOX008578; Tue, 7 Sep 2010 16:43:51 -0500 (CDT) Received: from dsbe71.ent.ti.com (localhost [127.0.0.1]) by dlep26.itg.ti.com (8.13.8/8.13.8) with ESMTP id o87Lhpeh024169; Tue, 7 Sep 2010 16:43:51 -0500 (CDT) Received: from dlee03.ent.ti.com ([157.170.170.18]) by dsbe71.ent.ti.com ([156.117.232.23]) with mapi; Tue, 7 Sep 2010 16:43:50 -0500 From: "Arce, Abraham" To: Eric Dumazet , David Miller CC: "netdev@vger.kernel.org" , "Shilimkar, Santosh" , "Ha, Tristram" Date: Tue, 7 Sep 2010 16:43:49 -0500 Subject: RE: NULL Pointer Deference: NFS & Telnet Thread-Topic: NULL Pointer Deference: NFS & Telnet Thread-Index: Acr9FN8ulzxEQE1eSVqFSwEjyyAwLwABmOAw Message-ID: <27F9C60D11D683428E133F85D2BB4A5304509AF8DA@dlee03.ent.ti.com> References: <27F9C60D11D683428E133F85D2BB4A53043E33A997@dlee03.ent.ti.com> <27F9C60D11D683428E133F85D2BB4A53043E3EDFE6@dlee03.ent.ti.com> <20100525.185236.193707791.davem@davemloft.net> <27F9C60D11D683428E133F85D2BB4A53043E3EDFF1@dlee03.ent.ti.com> <1274851741.25136.16.camel@edumazet-laptop> <27F9C60D11D683428E133F85D2BB4A53043E3EE6A3@dlee03.ent.ti.com> <1274906933.2542.17.camel@edumazet-laptop> In-Reply-To: <1274906933.2542.17.camel@edumazet-laptop> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Eric, David, > From: Eric Dumazet [mailto:eric.dumazet@gmail.com] [..] > > By increasing the allocation length of our rx skbuff the corruption issue is > fixed... I have increased it by 2... Were we writing outside our boundaries of > skb data? > > > > 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 ? FCS -> CRC is enable in hardware, under ks8851_net_open() TXCR_TXCRC | /* add CRC */ How about the following patch? I am using added helper function: netdev_alloc_skb_ip_align() Best Regards Abraham --- 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 --git a/drivers/net/ks8851.c b/drivers/net/ks8851.c index b4fb07a..df70a83 100644 --- a/drivers/net/ks8851.c +++ b/drivers/net/ks8851.c @@ -503,17 +503,14 @@ 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_ip_align(ks->netdev, 2 + rxlen); if (!skb) { /* todo - dump frame and move on */ } - /* two bytes to ensure ip is aligned, and four bytes - * 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 +523,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);