提交 c0ea452e 编写于 作者: M Michal Schmidt 提交者: 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: NMichal Schmidt <mschmidt@redhat.com>
Acked-by: NEilon Greenstein <eilong@broadcom.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 127d0a19
......@@ -10824,12 +10824,12 @@ do { \
int bnx2x_init_firmware(struct bnx2x *bp)
{
const char *fw_file_name;
struct bnx2x_fw_file_hdr *fw_hdr;
int rc;
if (!bp->firmware) {
const char *fw_file_name;
if (bp->firmware)
return 0;
if (CHIP_IS_E1(bp))
fw_file_name = FW_FILE_NAME_E1;
......@@ -10843,8 +10843,7 @@ int bnx2x_init_firmware(struct bnx2x *bp)
}
BNX2X_DEV_INFO("Loading %s\n", fw_file_name);
rc = request_firmware(&bp->firmware, fw_file_name,
&bp->pdev->dev);
rc = request_firmware(&bp->firmware, fw_file_name, &bp->pdev->dev);
if (rc) {
BNX2X_ERR("Can't load firmware file %s\n",
fw_file_name);
......@@ -10856,7 +10855,6 @@ int bnx2x_init_firmware(struct bnx2x *bp)
BNX2X_ERR("Corrupt firmware file %s\n", fw_file_name);
goto request_firmware_exit;
}
}
fw_hdr = (struct bnx2x_fw_file_hdr *)bp->firmware->data;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册