From: Arnd Bergmann <arnd@arndb.de>
To: Christian Benvenuti <benve@cisco.com>,
Nelson Escobar <neescoba@cisco.com>,
Parvi Kaustubhi <pkaustub@cisco.com>,
Doug Ledford <dledford@redhat.com>,
Jason Gunthorpe <jgg@ziepe.ca>
Cc: Arnd Bergmann <arnd@arndb.de>, Leon Romanovsky <leon@kernel.org>,
Gal Pressman <galpress@amazon.com>,
Parav Pandit <parav@mellanox.com>,
Davidlohr Bueso <dave@stgolabs.net>,
Kamal Heib <kamalheib1@gmail.com>,
Florian Westphal <fw@strlen.de>,
linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] usnic: avoid overly large buffers on stack
Date: Fri, 6 Sep 2019 17:57:17 +0200 [thread overview]
Message-ID: <20190906155730.2750200-1-arnd@arndb.de> (raw)
It's never a good idea to put a 1000-byte buffer on the kernel
stack. The compiler warns about this instance when usnic_ib_log_vf()
gets inlined into usnic_ib_pci_probe():
drivers/infiniband/hw/usnic/usnic_ib_main.c:543:12: error: stack frame size of 1044 bytes in function 'usnic_ib_pci_probe' [-Werror,-Wframe-larger-than=]
As this is only called for debugging purposes in the setup path,
it's trivial to convert to a dynamic allocation.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/infiniband/hw/usnic/usnic_ib_main.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/hw/usnic/usnic_ib_main.c b/drivers/infiniband/hw/usnic/usnic_ib_main.c
index 03f54eb9404b..c9abe1c01e4e 100644
--- a/drivers/infiniband/hw/usnic/usnic_ib_main.c
+++ b/drivers/infiniband/hw/usnic/usnic_ib_main.c
@@ -89,9 +89,15 @@ static void usnic_ib_dump_vf(struct usnic_ib_vf *vf, char *buf, int buf_sz)
void usnic_ib_log_vf(struct usnic_ib_vf *vf)
{
- char buf[1000];
- usnic_ib_dump_vf(vf, buf, sizeof(buf));
+ char *buf = kzalloc(1000, GFP_KERNEL);
+
+ if (!buf)
+ return;
+
+ usnic_ib_dump_vf(vf, buf, 1000);
usnic_dbg("%s\n", buf);
+
+ kfree(buf);
}
/* Start of netdev section */
--
2.20.0
next reply other threads:[~2019-09-06 15:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-06 15:57 Arnd Bergmann [this message]
2019-09-12 13:47 ` [PATCH] usnic: avoid overly large buffers on stack Jason Gunthorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190906155730.2750200-1-arnd@arndb.de \
--to=arnd@arndb.de \
--cc=benve@cisco.com \
--cc=dave@stgolabs.net \
--cc=dledford@redhat.com \
--cc=fw@strlen.de \
--cc=galpress@amazon.com \
--cc=jgg@ziepe.ca \
--cc=kamalheib1@gmail.com \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=neescoba@cisco.com \
--cc=parav@mellanox.com \
--cc=pkaustub@cisco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).