From patchwork Thu Apr 8 07:03:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abraham Arce X-Patchwork-Id: 49701 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 C6004B7CF7 for ; Thu, 8 Apr 2010 17:04:04 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758452Ab0DHHD7 (ORCPT ); Thu, 8 Apr 2010 03:03:59 -0400 Received: from mail-gy0-f174.google.com ([209.85.160.174]:47135 "EHLO mail-gy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758420Ab0DHHD6 (ORCPT ); Thu, 8 Apr 2010 03:03:58 -0400 Received: by gyg13 with SMTP id 13so1029316gyg.19 for ; Thu, 08 Apr 2010 00:03:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:received:message-id :subject:from:to:content-type; bh=d4XD5LDzv+rwXwO3gXU5fzl1rP8wrbyrXx9Fn3ghKis=; b=h+k7lgkPvU4gtEUFzaP5lAXrFynjidA16S5A04TGJ9ycQ9i3yRa2aQfcHvngofa54L TyORJ6RUT/ZJhsJuo/V2QY8Sz9IipDx2xF6MRoCYRzHO5+lcfdQ9s1tD9mm7uwB2dOUp UCrbg/+oJnRhwTymF6plmxMt0NGxgjgcJXbvU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=FLh7MI2mcOPLd31FZw/8etCFt45GB6mABsbkIFJ8416pULrkE/lt+vaHFd21OgrtyE P7B30CMJamsiE8vXoDnW2M1QC3BEvczlBsNf/zKYofwbGdyalCP4Rv/IGgs+bKQV6W94 ZtXiMMeRWXeDqij58Qpsj+pW/NNDSPyK+u1Vo= MIME-Version: 1.0 Received: by 10.231.37.195 with HTTP; Thu, 8 Apr 2010 00:03:57 -0700 (PDT) Date: Thu, 8 Apr 2010 02:03:57 -0500 Received: by 10.101.27.28 with SMTP id e28mr462149anj.136.1270710237364; Thu, 08 Apr 2010 00:03:57 -0700 (PDT) Message-ID: Subject: KS8851: Possible NULL dereferenced in ks8851_rx_pkts From: Abraham Arce To: netdev@vger.kernel.org Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hi, These changes avoid a possible dereference in skb_reserve when skb is NULL. I am increasing rx dropped packet count but not sure about how to handle the dump of frames. Any advice is appreciated. 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 d6dc29b..a1aa757 100644 --- a/drivers/net/ks8851.c +++ b/drivers/net/ks8851.c @@ -534,8 +534,11 @@ static void ks8851_rx_pkts(struct ks8851_net *ks) if (rxlen > 0) { skb = netdev_alloc_skb(ks->netdev, rxlen + 2 + 8); - if (!skb) { + if (unlikely(!skb)) { /* todo - dump frame and move on */ + ks_dbg(ks, "No free memory, packet dropped\n"); + ks->netdev->stats.rx_dropped++; + return; } /* two bytes to ensure ip is aligned, and four bytes