Commit 32927e28 authored by Mark Bloch's avatar Mark Bloch Committed by Jason Gunthorpe

IB/mlx5: Don't clean uninitialized UMR resources

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: 42cea83f ("IB/mlx5: Fix cleanup order on unload")
Signed-off-by: default avatarMark Bloch <markb@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent e8980d67
...@@ -3448,9 +3448,12 @@ static void destroy_umrc_res(struct mlx5_ib_dev *dev) ...@@ -3448,9 +3448,12 @@ static void destroy_umrc_res(struct mlx5_ib_dev *dev)
if (err) if (err)
mlx5_ib_warn(dev, "mr cache cleanup failed\n"); mlx5_ib_warn(dev, "mr cache cleanup failed\n");
mlx5_ib_destroy_qp(dev->umrc.qp); if (dev->umrc.qp)
ib_free_cq(dev->umrc.cq); mlx5_ib_destroy_qp(dev->umrc.qp);
ib_dealloc_pd(dev->umrc.pd); if (dev->umrc.cq)
ib_free_cq(dev->umrc.cq);
if (dev->umrc.pd)
ib_dealloc_pd(dev->umrc.pd);
} }
enum { enum {
...@@ -3552,12 +3555,15 @@ static int create_umr_res(struct mlx5_ib_dev *dev) ...@@ -3552,12 +3555,15 @@ static int create_umr_res(struct mlx5_ib_dev *dev)
error_4: error_4:
mlx5_ib_destroy_qp(qp); mlx5_ib_destroy_qp(qp);
dev->umrc.qp = NULL;
error_3: error_3:
ib_free_cq(cq); ib_free_cq(cq);
dev->umrc.cq = NULL;
error_2: error_2:
ib_dealloc_pd(pd); ib_dealloc_pd(pd);
dev->umrc.pd = NULL;
error_0: error_0:
kfree(attr); kfree(attr);
......
...@@ -739,6 +739,9 @@ int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev) ...@@ -739,6 +739,9 @@ int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev)
{ {
int i; int i;
if (!dev->cache.wq)
return 0;
dev->cache.stopped = 1; dev->cache.stopped = 1;
flush_workqueue(dev->cache.wq); flush_workqueue(dev->cache.wq);
......
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