Skip to content

Commit

Permalink
bnx2x: allocate memory dynamically in ethtool self-test.
Browse files Browse the repository at this point in the history
From: Merav Sicron <meravs@broadcom.com>

Current ethtool self tests usesa large buffer on stack. This patch replaces
that array by dynamically allocated memory

Signed-off-by: Merav Sicron <meravs@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Mintz Yuval authored and David S. Miller committed Feb 15, 2012
1 parent 817a8aa commit afa13b4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -2016,14 +2016,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);
Expand Down Expand Up @@ -2057,6 +2065,7 @@ static int bnx2x_test_nvram(struct bnx2x *bp)
}

test_nvram_exit:
kfree(buf);
return rc;
}

Expand Down

0 comments on commit afa13b4

Please sign in to comment.