From patchwork Wed Jun 2 10:48:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abraham Arce X-Patchwork-Id: 103741 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o52An1aW027961 for ; Wed, 2 Jun 2010 10:49:01 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755322Ab0FBKtA (ORCPT ); Wed, 2 Jun 2010 06:49:00 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:39905 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751610Ab0FBKs7 convert rfc822-to-8bit (ORCPT ); Wed, 2 Jun 2010 06:48:59 -0400 Received: from dlep33.itg.ti.com ([157.170.170.112]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id o52AmvVE018125 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 2 Jun 2010 05:48:58 -0500 Received: from dlep26.itg.ti.com (localhost [127.0.0.1]) by dlep33.itg.ti.com (8.13.7/8.13.7) with ESMTP id o52Amvip025123; Wed, 2 Jun 2010 05:48:57 -0500 (CDT) Received: from dlee74.ent.ti.com (localhost [127.0.0.1]) by dlep26.itg.ti.com (8.13.8/8.13.8) with ESMTP id o52Amv06004248; Wed, 2 Jun 2010 05:48:57 -0500 (CDT) Received: from dlee03.ent.ti.com ([157.170.170.18]) by dlee74.ent.ti.com ([157.170.170.8]) with mapi; Wed, 2 Jun 2010 05:48:57 -0500 From: "Arce, Abraham" To: Tony Lindgren CC: "linux-omap@vger.kernel.org" Date: Wed, 2 Jun 2010 05:48:55 -0500 Subject: [FOR TESTING] [PATCH] KS8851: Fix RX skbuff NULL pointer Thread-Topic: [FOR TESTING] [PATCH] KS8851: Fix RX skbuff NULL pointer Thread-Index: AcsCQTLECszunQ83QaGCGt+2RDeSSg== Message-ID: <27F9C60D11D683428E133F85D2BB4A53043E538A5F@dlee03.ent.ti.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 02 Jun 2010 10:49:01 +0000 (UTC) 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);