On 2/11/2019 07:40, Leon Romanovsky wrote: > From: Mark Bloch <markb@xxxxxxxxxxxx> > > Make sure the IB device is freed on failure. > > Fixes: b5ca15ad7e61 ("IB/mlx5: Add proper representors support") > Signed-off-by: Mark Bloch <markb@xxxxxxxxxxxx> > Reviewed-by: Bodong Wang <bodong@xxxxxxxxxxxx> > Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx> > --- > drivers/infiniband/hw/mlx5/ib_rep.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/infiniband/hw/mlx5/ib_rep.c b/drivers/infiniband/hw/mlx5/ib_rep.c > index 6d7b8bad4b61..ff663e0ec3c2 100644 > --- a/drivers/infiniband/hw/mlx5/ib_rep.c > +++ b/drivers/infiniband/hw/mlx5/ib_rep.c > @@ -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(&dev->ib_dev); > return -EINVAL; > + } > This is wrong :/ it should be: diff --git a/drivers/infiniband/hw/mlx5/ib_rep.c b/drivers/infiniband/hw/mlx5/ib_rep.c index 46a9ddc8ca56..07106bf394fa 100644 --- a/drivers/infiniband/hw/mlx5/ib_rep.c +++ b/drivers/infiniband/hw/mlx5/ib_rep.c @@ -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; > rep->rep_if[REP_IB].priv = ibdev; > >