From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753603AbbJGNLY (ORCPT ); Wed, 7 Oct 2015 09:11:24 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:60697 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751656AbbJGNLW (ORCPT ); Wed, 7 Oct 2015 09:11:22 -0400 From: Arnd Bergmann To: linux-scsi@vger.kernel.org Cc: QLogic-Storage-Upstream@qlogic.com, "James E.J. Bottomley" , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Joe Carnuccio , Chad Dupuis , Yuval Mintz , "David S. Miller" , netdev@vger.kernel.org Subject: [PATCH] bnx2fc: reduce stack usage in __bnx2fc_enable Date: Wed, 07 Oct 2015 15:11:04 +0200 Message-ID: <5002023.QHmpbQ8s70@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:oUo92sknE7Pz4QXjmu0RP2eO+9V4+vOdS1yKJaTqSvHYvvJyNPU LDtVgjyl5sCUaqSExOg7uuD1RvPjwXMXm9gg8J6UndbUcjtP1YxDmP0fWyCkzAg+bnr4R/N DYYXptusHw3FerY8alWbqQh7npBDqahSqqUd4YSaN0dFyBFltoyWT3Twdr6VrkN+p6Fs5kV KkirboGBoN7pnZj8vToRw== X-UI-Out-Filterresults: notjunk:1;V01:K0:FVLkaqYC6ac=:5sOKSxA8yHJ1ptTPP2hUj4 GUkBG3VODqyYozGTXuqluixkC/GvdaQ3KCv9/29JbwO+pLtKqzyHZpyjctUjSinXM2vohu8oX gs8OkSMGNMswDXJejaLcDuj96ZMMdzUOT2F/WLQYSczJF9C4dwdCkXTfVbTVjPWyiCyQkO+k3 QWiggPvYvNKkmnJMuJappRjGS0mbpy4EUJaWoLeLES0tWTlSRufrTpON8AmrkbCcLlyMpMU8w 4C10oToEbcgyW8gEnF+OBoi4LHqGbvOjJs9h39/m0IGBeAWVuudoBgV5I4YTRG3EWHQsH6HmJ pV/V+eJuGoeojO7wDC1JEPnxNnNDKbd2eUotN7ERi0m9h8hho4RzAx/vDHBrJJQj3bPGLYSJc x82mk8uKcrzadW8yDe8nYIiWcg9niRegqPNp3oQd/XYkaGieuZdy6BjF27D/1N2K4R9axYxlS JGVkALJX5v6BHgkHnerHskF4vlaOjedBg0Mj8zhgPoLWkOucMXVa8GSe6EqPGlfUAAjRiIZqs K78M4QWnpvPXxViQpCZSC55w8JlPQGUhN80vW7kEh82bw+8U7USWeW9oMWVHyEfcIRye48f9L sgnwSLn8ITPrGsYbeIoKB+KnQkDBoWkDZ4RX6xBiNZPXpJgMo+4Bz0KsRu2xySFNR8x1Dwawu ffxtxmVQw3ze2tgexZG3uWtW/LooLbufFGX9JYWvpzw4gS5d2wMpImB6W/Y0LiVM8K8m9J2KW M5dsMpzIiDq9GybA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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; }