Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1241474 > unrolled thread
| Started by | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| First post | 2015-10-07 15:20 +0200 |
| Last post | 2015-10-07 21:00 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] bnx2fc: reduce stack usage in __bnx2fc_enable Arnd Bergmann <arnd@arndb.de> - 2015-10-07 15:20 +0200
Re: [PATCH] bnx2fc: reduce stack usage in __bnx2fc_enable Maurizio Lombardi <mlombard@redhat.com> - 2015-10-07 15:30 +0200
Re: [PATCH] bnx2fc: reduce stack usage in __bnx2fc_enable Chad Dupuis <chad.dupuis@qlogic.com> - 2015-10-07 21:00 +0200
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Date | 2015-10-07 15:20 +0200 |
| Subject | [PATCH] bnx2fc: reduce stack usage in __bnx2fc_enable |
| Message-ID | <qgWNs-5TU-11@gated-at.bofh.it> |
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.")
---
The original patch was merged through netdev along with the respective
ethernet driver changes, but this should probably go through the scsi
tree, as no ethernet changes are involved.
diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index d5cdc4776707..72ba0dfae3e0 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -2092,7 +2092,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) {
@@ -2124,11 +2124,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;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Maurizio Lombardi <mlombard@redhat.com> |
|---|---|
| Date | 2015-10-07 15:30 +0200 |
| Message-ID | <qgWXa-65g-53@gated-at.bofh.it> |
| In reply to | #1241474 |
Hi, On 10/07/2015 03:11 PM, Arnd Bergmann wrote: > - 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; > If kzalloc() fails perhaps the function should return -ENOMEM, not zero. Regards, Maurizio Lombardi -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Chad Dupuis <chad.dupuis@qlogic.com> |
|---|---|
| Date | 2015-10-07 21:00 +0200 |
| Message-ID | <qh26t-4Xj-13@gated-at.bofh.it> |
| In reply to | #1241495 |
On Wed, 7 Oct 2015, Maurizio Lombardi wrote: > Hi, > > On 10/07/2015 03:11 PM, Arnd Bergmann wrote: >> - 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; >> > > If kzalloc() fails perhaps the function should return -ENOMEM, not zero. > The enablement of the fcoe interface can still proceed if this particular allocation fails so returning 0 would be appropriate here. This patch looks good to me. > > Regards, > Maurizio Lombardi > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web