summaryrefslogtreecommitdiff
path: root/drivers/scsi/bnx2fc
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2015-10-07 15:11:04 +0200
committerJames Bottomley <JBottomley@Odin.com>2015-11-09 17:10:24 -0800
commit720ba808e9ca276919f566bbe2b4e09c79f25faa (patch)
treeded0205bbdc7e55b5debaa10e4461e4a1ed1ea64 /drivers/scsi/bnx2fc
parente79504236548e4c909959ba444f87a12224555ac (diff)
bnx2fc: reduce stack usage in __bnx2fc_enable
When the bnx2fc driver was changed to read the npiv table from nvram, the stack of the __bnx2fc_enable function gained an additional 1028 byte structure that gcc rightfully warns about: drivers/scsi/bnx2fc/bnx2fc_fcoe.c: In function '__bnx2fc_enable': drivers/scsi/bnx2fc/bnx2fc_fcoe.c:2134:1: warning: the frame size of 1128 bytes is larger than 1024 bytes [-Wframe-larger-than=] In order to avoid a possible kernel stack overflow and to get rid of the warning, this changes the function to use a dynamic allocation of the structure using kzalloc. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Fixes: 2971ff67bd3 ("bnx2fc: Read npiv table from nvram and create vports.") Acked-by: Chad Dupuis <chad.dupuis@qlogic.com> Signed-off-by: James Bottomley <JBottomley@Odin.com>
Diffstat (limited to 'drivers/scsi/bnx2fc')
-rw-r--r--drivers/scsi/bnx2fc/bnx2fc_fcoe.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index b0bc5ffee903..29a1c03b558e 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -2091,7 +2091,7 @@ static int __bnx2fc_enable(struct fcoe_ctlr *ctlr)
{
struct bnx2fc_interface *interface = fcoe_ctlr_priv(ctlr);
struct bnx2fc_hba *hba;
- struct cnic_fc_npiv_tbl npiv_tbl;
+ struct cnic_fc_npiv_tbl *npiv_tbl;
struct fc_lport *lport;
if (interface->enabled == false) {
@@ -2123,11 +2123,16 @@ static int __bnx2fc_enable(struct fcoe_ctlr *ctlr)
if (!hba->cnic->get_fc_npiv_tbl)
goto done;
- memset(&npiv_tbl, 0, sizeof(npiv_tbl));
- if (hba->cnic->get_fc_npiv_tbl(hba->cnic, &npiv_tbl))
+ npiv_tbl = kzalloc(sizeof(struct cnic_fc_npiv_tbl), GFP_KERNEL);
+ if (!npiv_tbl)
goto done;
- bnx2fc_npiv_create_vports(lport, &npiv_tbl);
+ if (hba->cnic->get_fc_npiv_tbl(hba->cnic, npiv_tbl))
+ goto done_free;
+
+ bnx2fc_npiv_create_vports(lport, npiv_tbl);
+done_free:
+ kfree(npiv_tbl);
done:
return 0;
}