Skip to content

Commit

Permalink
IB/mlx5: Don't clean uninitialized UMR resources
Browse files Browse the repository at this point in the history
In case we failed to create UMR resources, mark them as invalid so we
won't try to destroy them on the unwind path.

Add the relevant checks to destroy_umrc_res(), this is done for the
unlikely event ib_register_device() or create_umr_res() err out and we
try to destroy invalid objects.

Fixes: 42cea83 ("IB/mlx5: Fix cleanup order on unload")
Signed-off-by: Mark Bloch <markb@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
  • Loading branch information
Mark Bloch authored and Jason Gunthorpe committed Mar 21, 2018
1 parent e8980d6 commit 32927e2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 9 additions & 3 deletions drivers/infiniband/hw/mlx5/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3448,9 +3448,12 @@ static void destroy_umrc_res(struct mlx5_ib_dev *dev)
if (err)
mlx5_ib_warn(dev, "mr cache cleanup failed\n");

mlx5_ib_destroy_qp(dev->umrc.qp);
ib_free_cq(dev->umrc.cq);
ib_dealloc_pd(dev->umrc.pd);
if (dev->umrc.qp)
mlx5_ib_destroy_qp(dev->umrc.qp);
if (dev->umrc.cq)
ib_free_cq(dev->umrc.cq);
if (dev->umrc.pd)
ib_dealloc_pd(dev->umrc.pd);
}

enum {
Expand Down Expand Up @@ -3552,12 +3555,15 @@ static int create_umr_res(struct mlx5_ib_dev *dev)

error_4:
mlx5_ib_destroy_qp(qp);
dev->umrc.qp = NULL;

error_3:
ib_free_cq(cq);
dev->umrc.cq = NULL;

error_2:
ib_dealloc_pd(pd);
dev->umrc.pd = NULL;

error_0:
kfree(attr);
Expand Down
3 changes: 3 additions & 0 deletions drivers/infiniband/hw/mlx5/mr.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,9 @@ int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev)
{
int i;

if (!dev->cache.wq)
return 0;

dev->cache.stopped = 1;
flush_workqueue(dev->cache.wq);

Expand Down

0 comments on commit 32927e2

Please sign in to comment.