aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/qlcnic
diff options
context:
space:
mode:
authorDan Carpenter <error27@gmail.com>2010-08-09 17:49:36 -0400
committerDavid S. Miller <davem@davemloft.net>2010-08-10 04:34:36 -0400
commite88db3bd46801a9c2cd0ac5e46122d47c285faec (patch)
tree090576e6117fa71d37d876e3b9143a63b649ce2d /drivers/net/qlcnic
parentca315ac22c1a91fc8047254b250599890d8a7b30 (diff)
qlcnic: using too much stack
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 <error27@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/qlcnic')
-rw-r--r--drivers/net/qlcnic/qlcnic_main.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/drivers/net/qlcnic/qlcnic_main.c b/drivers/net/qlcnic/qlcnic_main.c
index 6b8df55840c..bf6d87adda4 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)
473static int 473static int
474qlcnic_init_pci_info(struct qlcnic_adapter *adapter) 474qlcnic_init_pci_info(struct qlcnic_adapter *adapter)
475{ 475{
476 struct qlcnic_pci_info pci_info[QLCNIC_MAX_PCI_FUNC]; 476 struct qlcnic_pci_info *pci_info;
477 int i, ret = 0, err; 477 int i, ret = 0, err;
478 u8 pfn; 478 u8 pfn;
479 479
480 pci_info = kcalloc(QLCNIC_MAX_PCI_FUNC, sizeof(*pci_info), GFP_KERNEL);
481 if (!pci_info)
482 return -ENOMEM;
483
480 adapter->npars = kzalloc(sizeof(struct qlcnic_npar_info) * 484 adapter->npars = kzalloc(sizeof(struct qlcnic_npar_info) *
481 QLCNIC_MAX_PCI_FUNC, GFP_KERNEL); 485 QLCNIC_MAX_PCI_FUNC, GFP_KERNEL);
482 if (!adapter->npars) 486 if (!adapter->npars) {
483 return -ENOMEM; 487 err = -ENOMEM;
488 goto err_pci_info;
489 }
484 490
485 adapter->eswitch = kzalloc(sizeof(struct qlcnic_eswitch) * 491 adapter->eswitch = kzalloc(sizeof(struct qlcnic_eswitch) *
486 QLCNIC_NIU_MAX_XG_PORTS, GFP_KERNEL); 492 QLCNIC_NIU_MAX_XG_PORTS, GFP_KERNEL);
@@ -508,6 +514,7 @@ qlcnic_init_pci_info(struct qlcnic_adapter *adapter)
508 for (i = 0; i < QLCNIC_NIU_MAX_XG_PORTS; i++) 514 for (i = 0; i < QLCNIC_NIU_MAX_XG_PORTS; i++)
509 adapter->eswitch[i].flags |= QLCNIC_SWITCH_ENABLE; 515 adapter->eswitch[i].flags |= QLCNIC_SWITCH_ENABLE;
510 516
517 kfree(pci_info);
511 return 0; 518 return 0;
512 519
513err_eswitch: 520err_eswitch:
@@ -516,6 +523,8 @@ err_eswitch:
516err_npars: 523err_npars:
517 kfree(adapter->npars); 524 kfree(adapter->npars);
518 adapter->npars = NULL; 525 adapter->npars = NULL;
526err_pci_info:
527 kfree(pci_info);
519 528
520 return ret; 529 return ret;
521} 530}
@@ -3362,15 +3371,21 @@ qlcnic_sysfs_read_pci_config(struct file *file, struct kobject *kobj,
3362 struct device *dev = container_of(kobj, struct device, kobj); 3371 struct device *dev = container_of(kobj, struct device, kobj);
3363 struct qlcnic_adapter *adapter = dev_get_drvdata(dev); 3372 struct qlcnic_adapter *adapter = dev_get_drvdata(dev);
3364 struct qlcnic_pci_func_cfg pci_cfg[QLCNIC_MAX_PCI_FUNC]; 3373 struct qlcnic_pci_func_cfg pci_cfg[QLCNIC_MAX_PCI_FUNC];
3365 struct qlcnic_pci_info pci_info[QLCNIC_MAX_PCI_FUNC]; 3374 struct qlcnic_pci_info *pci_info;
3366 int i, ret; 3375 int i, ret;
3367 3376
3368 if (size != sizeof(pci_cfg)) 3377 if (size != sizeof(pci_cfg))
3369 return QL_STATUS_INVALID_PARAM; 3378 return QL_STATUS_INVALID_PARAM;
3370 3379
3380 pci_info = kcalloc(QLCNIC_MAX_PCI_FUNC, sizeof(*pci_info), GFP_KERNEL);
3381 if (!pci_info)
3382 return -ENOMEM;
3383
3371 ret = qlcnic_get_pci_info(adapter, pci_info); 3384 ret = qlcnic_get_pci_info(adapter, pci_info);
3372 if (ret) 3385 if (ret) {
3386 kfree(pci_info);
3373 return ret; 3387 return ret;
3388 }
3374 3389
3375 for (i = 0; i < QLCNIC_MAX_PCI_FUNC ; i++) { 3390 for (i = 0; i < QLCNIC_MAX_PCI_FUNC ; i++) {
3376 pci_cfg[i].pci_func = pci_info[i].id; 3391 pci_cfg[i].pci_func = pci_info[i].id;
@@ -3381,8 +3396,8 @@ qlcnic_sysfs_read_pci_config(struct file *file, struct kobject *kobj,
3381 memcpy(&pci_cfg[i].def_mac_addr, &pci_info[i].mac, ETH_ALEN); 3396 memcpy(&pci_cfg[i].def_mac_addr, &pci_info[i].mac, ETH_ALEN);
3382 } 3397 }
3383 memcpy(buf, &pci_cfg, size); 3398 memcpy(buf, &pci_cfg, size);
3399 kfree(pci_info);
3384 return size; 3400 return size;
3385
3386} 3401}
3387static struct bin_attribute bin_attr_npar_config = { 3402static struct bin_attribute bin_attr_npar_config = {
3388 .attr = {.name = "npar_config", .mode = (S_IRUGO | S_IWUSR)}, 3403 .attr = {.name = "npar_config", .mode = (S_IRUGO | S_IWUSR)},