Skip to content

Commit

Permalink
bnxt_en: take coredump_record structure off stack
Browse files Browse the repository at this point in the history
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: 6c5657d ("bnxt_en: Add support for ethtool get dump.")
Signed-off-by: Arnd Bergmann <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
arndb authored and davem330 committed Aug 14, 2018
1 parent cf87615 commit 1bbf3ae
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 1bbf3ae

Please sign in to comment.