Commit fc9e4477 authored by Mark Bloch's avatar Mark Bloch Committed by Jason Gunthorpe

RDMA/mlx5: Fix memory leak in case we fail to add an IB device

Make sure the IB device is freed on failure.

Fixes: b5ca15ad ("IB/mlx5: Add proper representors support")
Signed-off-by: default avatarMark Bloch <markb@mellanox.com>
Reviewed-by: default avatarBodong Wang <bodong@mellanox.com>
Reviewed-by: default avatarHåkon Bugge <haakon.bugge@oracle.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 0da4d48d
......@@ -78,8 +78,10 @@ mlx5_ib_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
ibdev->mdev = dev;
ibdev->num_ports = max(MLX5_CAP_GEN(dev, num_ports),
MLX5_CAP_GEN(dev, num_vhca_ports));
if (!__mlx5_ib_add(ibdev, &rep_profile))
if (!__mlx5_ib_add(ibdev, &rep_profile)) {
ib_dealloc_device(&ibdev->ib_dev);
return -EINVAL;
}
rep->rep_if[REP_IB].priv = ibdev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment