diff options
author | Colin Ian King <colin.king@canonical.com> | 2017-08-31 17:30:53 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-09-03 10:57:10 -0700 |
commit | 542deb88b0e3696ec9986e804628158169200776 (patch) | |
tree | f6b470e7e89468cb70fbdf0345e1d76d05700863 /drivers/net/ethernet/mellanox/mlx4/main.c | |
parent | 32d9b70a053a835b4dfb33158fc03795ea103e44 (diff) | |
download | op-kernel-dev-542deb88b0e3696ec9986e804628158169200776.zip op-kernel-dev-542deb88b0e3696ec9986e804628158169200776.tar.gz |
net/mlx4_core: fix memory leaks on error exit path
The structures hca_param and func_cap are not being kfree'd on an error
exit path causing two memory leaks. Fix this by jumping to the existing
free memory error exit path.
Detected by CoverityScan, CID#1455219, CID#1455224 ("Resource Leak")
Fixes: c73c8b1e47ca ("net/mlx4_core: Dynamically allocate structs at mlx4_slave_cap")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/mellanox/mlx4/main.c')
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/main.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c index c631d15..b3e50f4 100644 --- a/drivers/net/ethernet/mellanox/mlx4/main.c +++ b/drivers/net/ethernet/mellanox/mlx4/main.c @@ -977,7 +977,8 @@ static int mlx4_slave_cap(struct mlx4_dev *dev) if (dev->caps.num_ports > MLX4_MAX_PORTS) { mlx4_err(dev, "HCA has %d ports, but we only support %d, aborting\n", dev->caps.num_ports, MLX4_MAX_PORTS); - return -ENODEV; + err = -ENODEV; + goto free_mem; } mlx4_replace_zero_macs(dev); |