From: Merav Sicron Date: Wed, 15 Feb 2012 02:10:27 +0000 (+0000) Subject: bnx2x: allocate memory dynamically in ethtool self-test. X-Git-Tag: v2.6.39-400.9.0~423^2~19^2~11^2~481 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=3fcffef181273fcc0138f9b03e753542a6c3f214;p=users%2Fjedix%2Flinux-maple.git bnx2x: allocate memory dynamically in ethtool self-test. Current ethtool self tests usesa large buffer on stack. This patch replaces that array by dynamically allocated memory (cherry picked from commit afa13b4b94bc4b3247fa46dd8698c8dbfe1a615c) Signed-off-by: Merav Sicron Signed-off-by: Eilon Greenstein Signed-off-by: David S. Miller Signed-off-by: Joe Jin --- diff --git a/drivers/net/bnx2x/bnx2x_ethtool.c b/drivers/net/bnx2x/bnx2x_ethtool.c index 67c2e1a9c16eb..08bde083199eb 100644 --- a/drivers/net/bnx2x/bnx2x_ethtool.c +++ b/drivers/net/bnx2x/bnx2x_ethtool.c @@ -2018,14 +2018,22 @@ static int bnx2x_test_nvram(struct bnx2x *bp) { 0x708, 0x70 }, /* manuf_key_info */ { 0, 0 } }; - __be32 buf[0x350 / 4]; - u8 *data = (u8 *)buf; + __be32 *buf; + u8 *data; int i, rc; u32 magic, crc; if (BP_NOMCP(bp)) return 0; + buf = kmalloc(0x350, GFP_KERNEL); + if (!buf) { + DP(NETIF_MSG_PROBE, "kmalloc failed\n"); + rc = -ENOMEM; + goto test_nvram_exit; + } + data = (u8 *)buf; + rc = bnx2x_nvram_read(bp, 0, data, 4); if (rc) { DP(NETIF_MSG_PROBE, "magic value read (rc %d)\n", rc); @@ -2059,6 +2067,7 @@ static int bnx2x_test_nvram(struct bnx2x *bp) } test_nvram_exit: + kfree(buf); return rc; }