From patchwork Mon Aug 9 10:37:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 61263 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 31BF0B70CE for ; Mon, 9 Aug 2010 20:39:44 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756108Ab0HIKji (ORCPT ); Mon, 9 Aug 2010 06:39:38 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:40151 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756092Ab0HIKjh (ORCPT ); Mon, 9 Aug 2010 06:39:37 -0400 Received: by wyb39 with SMTP id 39so9716928wyb.19 for ; Mon, 09 Aug 2010 03:39:35 -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=h3zG1jSgYWNC9+I7fvv+irFIEOLGrZxv3XWPkuPvoZs=; b=aJaGCx3v4MabJ3mFPF7cnq6ybdKPziCwvX9Kh9GF4IOWcfVmWvIZeHTUL558BtT1dU eXgSawoqX5fOpjNf0wis8V8zpNy+gSM10s010tR42V8xDoKxLDtWT27o1wvFHYRlmdNa dPIk7pKJxjzNAoWLk9v4lE5slONKkEwsDEV/s= 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=L9PGLvMxB+JqkZTAOkNwnTW0pX0DxJb5KZMn8kfdmm3J7enP6U3ifN+6mIuxg5sLyT k092HM11eRghz/rW396lTKWUBmOeoTbv3p+aRpmYmcDurB/b4s6oSuckrUhBUrl9GZvu UbyhpOaihQGFwvm48aqmcOCbTYIkhz5OMlPCw= Received: by 10.216.3.12 with SMTP id 12mr2413677weg.109.1281350375839; Mon, 09 Aug 2010 03:39:35 -0700 (PDT) Received: from bicker ([41.205.146.22]) by mx.google.com with ESMTPS id v44sm2456127weq.28.2010.08.09.03.38.27 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 09 Aug 2010 03:39:35 -0700 (PDT) Date: Mon, 9 Aug 2010 12:37:27 +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] qlcnic: using too much stack Message-ID: <20100809103727.GH9031@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 --- 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 7f27e2a..da84229 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->eswitch = 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)},