From: Arnd Bergmann <arnd@arndb.de>
To: Michael Chan <michael.chan@broadcom.com>,
"David S. Miller" <davem@davemloft.net>
Cc: Arnd Bergmann <arnd@arndb.de>,
Vasundhara Volam <vasundhara-v.volam@broadcom.com>,
Andy Gospodarek <gospo@broadcom.com>,
Scott Branden <scott.branden@broadcom.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] bnxt_en: take coredump_record structure off stack
Date: Tue, 14 Aug 2018 00:12:45 +0200 [thread overview]
Message-ID: <20180813221256.299221-1-arnd@arndb.de> (raw)
The bnxt_coredump_record structure is very long, causing a warning
about possible stack overflow on 32-bit architectures:
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c: In function 'bnxt_get_coredump':
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c:2989:1: error: the frame size of 1188 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
I could not see any reason to operate on an on-stack copy of the
structure before copying it back into the caller-provided buffer, which
also simplifies the code here.
Fixes: 6c5657d085ae ("bnxt_en: Add support for ethtool get dump.")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
index 539be1d1b67f..e52d7af3ab3e 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
@@ -2900,7 +2900,6 @@ static int bnxt_get_coredump(struct bnxt *bp, void *buf, u32 *dump_len)
struct coredump_segment_record *seg_record = NULL;
u32 offset = 0, seg_hdr_len, seg_record_len;
struct bnxt_coredump_segment_hdr seg_hdr;
- struct bnxt_coredump_record coredump_rec;
struct bnxt_coredump coredump = {NULL};
time64_t start_time;
u16 start_utc;
@@ -2976,14 +2975,12 @@ static int bnxt_get_coredump(struct bnxt *bp, void *buf, u32 *dump_len)
}
err:
- if (buf) {
- bnxt_fill_coredump_record(bp, &coredump_rec, start_time,
+ if (buf)
+ bnxt_fill_coredump_record(bp, buf + offset, start_time,
start_utc, coredump.total_segs + 1,
rc);
- memcpy(buf + offset, &coredump_rec, sizeof(coredump_rec));
- }
kfree(coredump.data);
- *dump_len += sizeof(coredump_rec);
+ *dump_len += sizeof(struct bnxt_coredump_record);
return rc;
}
--
2.18.0
next reply other threads:[~2018-08-13 22:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-13 22:12 Arnd Bergmann [this message]
2018-08-14 3:46 ` [PATCH] bnxt_en: take coredump_record structure off stack David Miller
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=20180813221256.299221-1-arnd@arndb.de \
--to=arnd@arndb.de \
--cc=davem@davemloft.net \
--cc=gospo@broadcom.com \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.chan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=scott.branden@broadcom.com \
--cc=vasundhara-v.volam@broadcom.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