Commit c0ea452e authored by Michal Schmidt's avatar Michal Schmidt Committed by David S. Miller

bnx2x: fix memory leak in bnx2x_init_firmware()

When cycling the interface down and up, bnx2x_init_firmware() knows that
the firmware is already loaded, but nevertheless it allocates certain
arrays anew (init_data, init_ops, init_ops_offsets, iro_arr). The old
arrays are leaked.

Fix the leaks by returning early if the firmware was already loaded.
Because if the firmware is loaded, so are the arrays.
Signed-off-by: default avatarMichal Schmidt <mschmidt@redhat.com>
Acked-by: default avatarEilon Greenstein <eilong@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 127d0a19
...@@ -10824,38 +10824,36 @@ do { \ ...@@ -10824,38 +10824,36 @@ do { \
int bnx2x_init_firmware(struct bnx2x *bp) int bnx2x_init_firmware(struct bnx2x *bp)
{ {
const char *fw_file_name;
struct bnx2x_fw_file_hdr *fw_hdr; struct bnx2x_fw_file_hdr *fw_hdr;
int rc; int rc;
if (bp->firmware)
return 0;
if (!bp->firmware) { if (CHIP_IS_E1(bp))
const char *fw_file_name; fw_file_name = FW_FILE_NAME_E1;
else if (CHIP_IS_E1H(bp))
if (CHIP_IS_E1(bp)) fw_file_name = FW_FILE_NAME_E1H;
fw_file_name = FW_FILE_NAME_E1; else if (!CHIP_IS_E1x(bp))
else if (CHIP_IS_E1H(bp)) fw_file_name = FW_FILE_NAME_E2;
fw_file_name = FW_FILE_NAME_E1H; else {
else if (!CHIP_IS_E1x(bp)) BNX2X_ERR("Unsupported chip revision\n");
fw_file_name = FW_FILE_NAME_E2; return -EINVAL;
else { }
BNX2X_ERR("Unsupported chip revision\n"); BNX2X_DEV_INFO("Loading %s\n", fw_file_name);
return -EINVAL;
}
BNX2X_DEV_INFO("Loading %s\n", fw_file_name);
rc = request_firmware(&bp->firmware, fw_file_name, rc = request_firmware(&bp->firmware, fw_file_name, &bp->pdev->dev);
&bp->pdev->dev); if (rc) {
if (rc) { BNX2X_ERR("Can't load firmware file %s\n",
BNX2X_ERR("Can't load firmware file %s\n", fw_file_name);
fw_file_name); goto request_firmware_exit;
goto request_firmware_exit; }
}
rc = bnx2x_check_firmware(bp); rc = bnx2x_check_firmware(bp);
if (rc) { if (rc) {
BNX2X_ERR("Corrupt firmware file %s\n", fw_file_name); BNX2X_ERR("Corrupt firmware file %s\n", fw_file_name);
goto request_firmware_exit; goto request_firmware_exit;
}
} }
fw_hdr = (struct bnx2x_fw_file_hdr *)bp->firmware->data; fw_hdr = (struct bnx2x_fw_file_hdr *)bp->firmware->data;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment