From patchwork Thu Jul 22 11:16:48 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 59564 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 6C22FB70D6 for ; Thu, 22 Jul 2010 21:17:50 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759254Ab0GVLRo (ORCPT ); Thu, 22 Jul 2010 07:17:44 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:63064 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759181Ab0GVLRm (ORCPT ); Thu, 22 Jul 2010 07:17:42 -0400 Received: by fxm14 with SMTP id 14so4187071fxm.19 for ; Thu, 22 Jul 2010 04:17:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:mime-version:content-type:content-disposition:user-agent; bh=/doNcQ+G0iNCkOD+lCJzVT9iNESlPWUiugiTDM5JgXk=; b=MZHSAe779dMy/avqiM4wT2fEkain8+RjKrdJFAJVytPwOtAbclK9M15bDFhLS6MypV JLmJzyaEVMzz9mufx+4fwcRL6WwNjQWoxPpBWAomltdoAt1SjgBXjg+xdqwPhUxlZ5XM usIsNZkw/D5qYAKxKk4wSiTU9t6DUu2Gvn374= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=g3zpcJ6kOJsKnyvP1x/7LyILpvUoT3AZ6kQmZXuPkJINL8OccdxSob8WdgqeJGSQ0H +6Q7ye3aISrJd859b1+2JKtusAkq47XGrIK1Wp0trWz3TfHQZAPsNlAe7p7sWTmc2Diw wB1+EuQhuV5dCpVXGCeyJMIkmwPA1ZwNN1FaE= Received: by 10.86.52.17 with SMTP id z17mr1476095fgz.4.1279797461150; Thu, 22 Jul 2010 04:17:41 -0700 (PDT) Received: from bicker ([205.177.176.130]) by mx.google.com with ESMTPS id a9sm3280413faa.3.2010.07.22.04.17.23 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 22 Jul 2010 04:17:40 -0700 (PDT) Date: Thu, 22 Jul 2010 13:16:48 +0200 From: Dan Carpenter To: Giuseppe Cavallaro Cc: "David S. Miller" , netdev@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch -next] stmmac: handle allocation errors in setup functions Message-ID: <20100722111648.GD17585@bicker> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org If the allocations fail in either dwmac1000_setup() or dwmac100_setup() then return NULL. These are called from stmmac_mac_device_setup(). The check for NULL returns in stmmac_mac_device_setup() needed to be moved forward a couple lines. Signed-off-by: Dan Carpenter --- 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/stmmac/dwmac1000_core.c b/drivers/net/stmmac/dwmac1000_core.c index 917b4e1..2b2f5c8 100644 --- a/drivers/net/stmmac/dwmac1000_core.c +++ b/drivers/net/stmmac/dwmac1000_core.c @@ -220,6 +220,8 @@ struct mac_device_info *dwmac1000_setup(unsigned long ioaddr) ((uid & 0x0000ff00) >> 8), (uid & 0x000000ff)); mac = kzalloc(sizeof(const struct mac_device_info), GFP_KERNEL); + if (!mac) + return NULL; mac->mac = &dwmac1000_ops; mac->dma = &dwmac1000_dma_ops; diff --git a/drivers/net/stmmac/dwmac100_core.c b/drivers/net/stmmac/dwmac100_core.c index 6f270a0..2fb165f 100644 --- a/drivers/net/stmmac/dwmac100_core.c +++ b/drivers/net/stmmac/dwmac100_core.c @@ -179,6 +179,8 @@ struct mac_device_info *dwmac100_setup(unsigned long ioaddr) struct mac_device_info *mac; mac = kzalloc(sizeof(const struct mac_device_info), GFP_KERNEL); + if (!mac) + return NULL; pr_info("\tDWMAC100\n"); diff --git a/drivers/net/stmmac/stmmac_main.c b/drivers/net/stmmac/stmmac_main.c index acf0616..0bdd332 100644 --- a/drivers/net/stmmac/stmmac_main.c +++ b/drivers/net/stmmac/stmmac_main.c @@ -1558,15 +1558,15 @@ static int stmmac_mac_device_setup(struct net_device *dev) else device = dwmac100_setup(ioaddr); + if (!device) + return -ENOMEM; + if (priv->enh_desc) { device->desc = &enh_desc_ops; pr_info("\tEnhanced descriptor structure\n"); } else device->desc = &ndesc_ops; - if (!device) - return -ENOMEM; - priv->hw = device; priv->wolenabled = priv->hw->pmt; /* PMT supported */