bnx2x: Fix VF memory leak unload
authorAriel Elior <ariele@broadcom.com>
Tue, 27 Aug 2013 22:13:03 +0000 (01:13 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 28 Aug 2013 02:03:04 +0000 (22:03 -0400)
Due to incorrect VF/PF conditions, when unloading a VF it will not release
part of the memory it has previously allocated.

Signed-off-by: Ariel Elior <ariele@broadcom.com>
Signed-off-by: Yuval Mintz <yuvalmin@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c

index 26b4dfcc00872b615d79b1489d0c1495eb3b8ad4..0cc26110868d409f00d551fbf1cc3c9c00a8b9bf 100644 (file)
@@ -2962,8 +2962,9 @@ int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode, bool keep_link)
        if (IS_PF(bp)) {
                if (CNIC_LOADED(bp))
                        bnx2x_free_mem_cnic(bp);
-               bnx2x_free_mem(bp);
        }
+       bnx2x_free_mem(bp);
+
        bp->state = BNX2X_STATE_CLOSED;
        bp->cnic_loaded = false;
 
index 8bdc8b9730074159f64411b818114c48727a08a5..1627a4e09c32fd3980f7db8bbfc686621391b393 100644 (file)
@@ -7855,12 +7855,15 @@ void bnx2x_free_mem(struct bnx2x *bp)
 {
        int i;
 
-       BNX2X_PCI_FREE(bp->def_status_blk, bp->def_status_blk_mapping,
-                      sizeof(struct host_sp_status_block));
-
        BNX2X_PCI_FREE(bp->fw_stats, bp->fw_stats_mapping,
                       bp->fw_stats_data_sz + bp->fw_stats_req_sz);
 
+       if (IS_VF(bp))
+               return;
+
+       BNX2X_PCI_FREE(bp->def_status_blk, bp->def_status_blk_mapping,
+                      sizeof(struct host_sp_status_block));
+
        BNX2X_PCI_FREE(bp->slowpath, bp->slowpath_mapping,
                       sizeof(struct bnx2x_slowpath));