From patchwork Tue Aug 10 07:49:36 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 61342 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 B0313B6EF2 for ; Tue, 10 Aug 2010 17:50:29 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755740Ab0HJHu0 (ORCPT ); Tue, 10 Aug 2010 03:50:26 -0400 Received: from mail-ey0-f174.google.com ([209.85.215.174]:41886 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753416Ab0HJHuY (ORCPT ); Tue, 10 Aug 2010 03:50:24 -0400 Received: by eya25 with SMTP id 25so3702637eya.19 for ; Tue, 10 Aug 2010 00:50:22 -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=UuKh+3HxvNnnQwhMymTfRCbHFaL8dhMpBKOo4vvi854=; b=SBAMNPdbSkCfUf3H/6jrSkZbvaViKPCYQA6h9Jh24xxMCtfX1cxuZ7DHn6TVYTEPRA EvBYvsVFMV86UzHiJJ8/KkwonsPbfb30gKFaQJOCOplpKOCDPKy3O0053evzIqAsrhjQ oVnpPtjQFCI+nxyHzBhKrbDrinnr08vQlRye0= 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=TwqpBVplYHvWQGHAWyH2JNCHvsoxD95+fwYJfcM3fvteEgWNfvKV3Bnn3qm1fzr3LL vXreDl3KtKowKTXvNYX44cWmAMTrU+qszgyM419LxMkZ+S+JFFDaBnHwce+Sp7KSwlBJ cng+7Ds9/5ON+4jxGDCPhCeDvZWRidusIQgEM= Received: by 10.213.31.84 with SMTP id x20mr2508765ebc.62.1281426622727; Tue, 10 Aug 2010 00:50:22 -0700 (PDT) Received: from bicker ([205.177.176.130]) by mx.google.com with ESMTPS id v8sm9295757eeh.2.2010.08.10.00.49.55 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 10 Aug 2010 00:50:22 -0700 (PDT) Date: Tue, 10 Aug 2010 09:49:36 +0200 From: Dan Carpenter To: Amit Kumar Salecha Cc: Anirban Chakraborty , linux-driver@qlogic.com, "David S. Miller" , Sucheta Chakraborty , netdev@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch 2/2 v2] qlcnic: using too much stack Message-ID: <20100810074936.GG18431@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 qlcnic_pci_info structs are 128 bytes so an array of 8 uses 1024 bytes. That's a lot if you run with 4K stacks. I allocated them with kcalloc() instead. Signed-off-by: Dan Carpenter --- V2: No change. I had to respin because of the 1/1 patch. -- 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/qlcnic/qlcnic_main.c b/drivers/net/qlcnic/qlcnic_main.c index 6b8df55..bf6d87a 100644 --- a/drivers/net/qlcnic/qlcnic_main.c +++ b/drivers/net/qlcnic/qlcnic_main.c @@ -473,14 +473,20 @@ qlcnic_cleanup_pci_map(struct qlcnic_adapter *adapter) static int qlcnic_init_pci_info(struct qlcnic_adapter *adapter) { - struct qlcnic_pci_info pci_info[QLCNIC_MAX_PCI_FUNC]; + struct qlcnic_pci_info *pci_info; int i, ret = 0, err; u8 pfn; + pci_info = kcalloc(QLCNIC_MAX_PCI_FUNC, sizeof(*pci_info), GFP_KERNEL); + if (!pci_info) + return -ENOMEM; + adapter->npars = kzalloc(sizeof(struct qlcnic_npar_info) * QLCNIC_MAX_PCI_FUNC, GFP_KERNEL); - if (!adapter->npars) - return -ENOMEM; + if (!adapter->npars) { + err = -ENOMEM; + goto err_pci_info; + } adapter->eswitch = kzalloc(sizeof(struct qlcnic_eswitch) * QLCNIC_NIU_MAX_XG_PORTS, GFP_KERNEL); @@ -508,6 +514,7 @@ qlcnic_init_pci_info(struct qlcnic_adapter *adapter) for (i = 0; i < QLCNIC_NIU_MAX_XG_PORTS; i++) adapter->eswitch[i].flags |= QLCNIC_SWITCH_ENABLE; + kfree(pci_info); return 0; err_eswitch: @@ -516,6 +523,8 @@ err_eswitch: err_npars: kfree(adapter->npars); adapter->npars = NULL; +err_pci_info: + kfree(pci_info); return ret; } @@ -3362,15 +3371,21 @@ qlcnic_sysfs_read_pci_config(struct file *file, struct kobject *kobj, struct device *dev = container_of(kobj, struct device, kobj); struct qlcnic_adapter *adapter = dev_get_drvdata(dev); struct qlcnic_pci_func_cfg pci_cfg[QLCNIC_MAX_PCI_FUNC]; - struct qlcnic_pci_info pci_info[QLCNIC_MAX_PCI_FUNC]; + struct qlcnic_pci_info *pci_info; int i, ret; if (size != sizeof(pci_cfg)) return QL_STATUS_INVALID_PARAM; + pci_info = kcalloc(QLCNIC_MAX_PCI_FUNC, sizeof(*pci_info), GFP_KERNEL); + if (!pci_info) + return -ENOMEM; + ret = qlcnic_get_pci_info(adapter, pci_info); - if (ret) + if (ret) { + kfree(pci_info); return ret; + } for (i = 0; i < QLCNIC_MAX_PCI_FUNC ; i++) { pci_cfg[i].pci_func = pci_info[i].id; @@ -3381,8 +3396,8 @@ qlcnic_sysfs_read_pci_config(struct file *file, struct kobject *kobj, memcpy(&pci_cfg[i].def_mac_addr, &pci_info[i].mac, ETH_ALEN); } memcpy(buf, &pci_cfg, size); + kfree(pci_info); return size; - } static struct bin_attribute bin_attr_npar_config = { .attr = {.name = "npar_config", .mode = (S_IRUGO | S_IWUSR)},