aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2012-03-15 10:08:29 -0400
committerDavid S. Miller <davem@davemloft.net>2012-03-16 04:57:26 -0400
commitc0ea452e422a1fc78ec8c639df64012d0b8dbb4a (patch)
tree372e3246e5f51cf490a760e1d49de60263d53d2e
parent127d0a198a310970b31866af8bbb6d4b1068e546 (diff)
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: Michal Schmidt <mschmidt@redhat.com> Acked-by: Eilon Greenstein <eilong@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c50
1 files changed, 24 insertions, 26 deletions
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 00ff62f92858..b69f8762b339 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -10824,38 +10824,36 @@ do { \
10824 10824
10825int bnx2x_init_firmware(struct bnx2x *bp) 10825int bnx2x_init_firmware(struct bnx2x *bp)
10826{ 10826{
10827 const char *fw_file_name;
10827 struct bnx2x_fw_file_hdr *fw_hdr; 10828 struct bnx2x_fw_file_hdr *fw_hdr;
10828 int rc; 10829 int rc;
10829 10830
10831 if (bp->firmware)
10832 return 0;
10830 10833
10831 if (!bp->firmware) { 10834 if (CHIP_IS_E1(bp))
10832 const char *fw_file_name; 10835 fw_file_name = FW_FILE_NAME_E1;
10833 10836 else if (CHIP_IS_E1H(bp))
10834 if (CHIP_IS_E1(bp)) 10837 fw_file_name = FW_FILE_NAME_E1H;
10835 fw_file_name = FW_FILE_NAME_E1; 10838 else if (!CHIP_IS_E1x(bp))
10836 else if (CHIP_IS_E1H(bp)) 10839 fw_file_name = FW_FILE_NAME_E2;
10837 fw_file_name = FW_FILE_NAME_E1H; 10840 else {
10838 else if (!CHIP_IS_E1x(bp)) 10841 BNX2X_ERR("Unsupported chip revision\n");
10839 fw_file_name = FW_FILE_NAME_E2; 10842 return -EINVAL;
10840 else { 10843 }
10841 BNX2X_ERR("Unsupported chip revision\n"); 10844 BNX2X_DEV_INFO("Loading %s\n", fw_file_name);
10842 return -EINVAL;
10843 }
10844 BNX2X_DEV_INFO("Loading %s\n", fw_file_name);
10845 10845
10846 rc = request_firmware(&bp->firmware, fw_file_name, 10846 rc = request_firmware(&bp->firmware, fw_file_name, &bp->pdev->dev);
10847 &bp->pdev->dev); 10847 if (rc) {
10848 if (rc) { 10848 BNX2X_ERR("Can't load firmware file %s\n",
10849 BNX2X_ERR("Can't load firmware file %s\n", 10849 fw_file_name);
10850 fw_file_name); 10850 goto request_firmware_exit;
10851 goto request_firmware_exit; 10851 }
10852 }
10853 10852
10854 rc = bnx2x_check_firmware(bp); 10853 rc = bnx2x_check_firmware(bp);
10855 if (rc) { 10854 if (rc) {
10856 BNX2X_ERR("Corrupt firmware file %s\n", fw_file_name); 10855 BNX2X_ERR("Corrupt firmware file %s\n", fw_file_name);
10857 goto request_firmware_exit; 10856 goto request_firmware_exit;
10858 }
10859 } 10857 }
10860 10858
10861 fw_hdr = (struct bnx2x_fw_file_hdr *)bp->firmware->data; 10859 fw_hdr = (struct bnx2x_fw_file_hdr *)bp->firmware->data;