From patchwork Wed Oct 7 13:11:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 7345131 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 058EFBEEA4 for ; Wed, 7 Oct 2015 13:11:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EE6752060A for ; Wed, 7 Oct 2015 13:11:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1541B20608 for ; Wed, 7 Oct 2015 13:11:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752818AbbJGNLX (ORCPT ); Wed, 7 Oct 2015 09:11:23 -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 Received: from wuerfel.localnet ([149.172.15.242]) by mrelayeu.kundenserver.de (mreue104) with ESMTPSA (Nemesis) id 0MZls6-1a381z0fB0-00LY2A; Wed, 07 Oct 2015 15:11:09 +0200 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 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-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" 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/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; }