mlx4_core: Fix memory leaks in SR-IOV error paths
authorDotan Barak <dotanb@dev.mellanox.co.il>
Thu, 29 May 2014 13:30:59 +0000 (16:30 +0300)
committerRoland Dreier <roland@purestorage.com>
Fri, 30 May 2014 04:12:58 +0000 (21:12 -0700)
Fix a few memory leaks that happen if errors happen in SR-IOV mode.

Signed-off-by: Dotan Barak <dotanb@dev.mellanox.co.il>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
drivers/net/ethernet/mellanox/mlx4/main.c

index 7cf9dadcb471bbfee9ef32761123ece4ceac131d..12a7ee2e60989ba9044f6d230b06a072a90cb49f 100644 (file)
@@ -1696,6 +1696,13 @@ unmap_bf:
        unmap_internal_clock(dev);
        unmap_bf_area(dev);
 
+       if (mlx4_is_slave(dev)) {
+               kfree(dev->caps.qp0_tunnel);
+               kfree(dev->caps.qp0_proxy);
+               kfree(dev->caps.qp1_tunnel);
+               kfree(dev->caps.qp1_proxy);
+       }
+
 err_close:
        if (mlx4_is_slave(dev))
                mlx4_slave_exit(dev);
@@ -2565,6 +2572,13 @@ err_master_mfunc:
        if (mlx4_is_master(dev))
                mlx4_multi_func_cleanup(dev);
 
+       if (mlx4_is_slave(dev)) {
+               kfree(dev->caps.qp0_tunnel);
+               kfree(dev->caps.qp0_proxy);
+               kfree(dev->caps.qp1_tunnel);
+               kfree(dev->caps.qp1_proxy);
+       }
+
 err_close:
        if (dev->flags & MLX4_FLAG_MSI_X)
                pci_disable_msix(pdev);