net/mlx5: Fix mlx5_get_uars_page to return error code
Change mlx5_get_uars_page to return ERR_PTR in case of
allocation failure. Change all callers accordingly to
check the IS_ERR(ptr) instead of NULL.
Fixes: 59211bd3b6
("net/mlx5: Split the load/unload flow into hardware and software flows")
Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com>
Signed-off-by: Eugenia Emantayev <eugenia@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
This commit is contained in:
parent
b6908c2960
commit
72f36be061
|
@ -4160,7 +4160,7 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
|
|||
goto err_cnt;
|
||||
|
||||
dev->mdev->priv.uar = mlx5_get_uars_page(dev->mdev);
|
||||
if (!dev->mdev->priv.uar)
|
||||
if (IS_ERR(dev->mdev->priv.uar))
|
||||
goto err_cong;
|
||||
|
||||
err = mlx5_alloc_bfreg(dev->mdev, &dev->bfreg, false, false);
|
||||
|
|
|
@ -1135,8 +1135,9 @@ static int mlx5_load_one(struct mlx5_core_dev *dev, struct mlx5_priv *priv,
|
|||
}
|
||||
|
||||
dev->priv.uar = mlx5_get_uars_page(dev);
|
||||
if (!dev->priv.uar) {
|
||||
if (IS_ERR(dev->priv.uar)) {
|
||||
dev_err(&pdev->dev, "Failed allocating uar, aborting\n");
|
||||
err = PTR_ERR(dev->priv.uar);
|
||||
goto err_disable_msix;
|
||||
}
|
||||
|
||||
|
|
|
@ -168,18 +168,16 @@ struct mlx5_uars_page *mlx5_get_uars_page(struct mlx5_core_dev *mdev)
|
|||
struct mlx5_uars_page *ret;
|
||||
|
||||
mutex_lock(&mdev->priv.bfregs.reg_head.lock);
|
||||
if (list_empty(&mdev->priv.bfregs.reg_head.list)) {
|
||||
ret = alloc_uars_page(mdev, false);
|
||||
if (IS_ERR(ret)) {
|
||||
ret = NULL;
|
||||
goto out;
|
||||
}
|
||||
list_add(&ret->list, &mdev->priv.bfregs.reg_head.list);
|
||||
} else {
|
||||
if (!list_empty(&mdev->priv.bfregs.reg_head.list)) {
|
||||
ret = list_first_entry(&mdev->priv.bfregs.reg_head.list,
|
||||
struct mlx5_uars_page, list);
|
||||
kref_get(&ret->ref_count);
|
||||
goto out;
|
||||
}
|
||||
ret = alloc_uars_page(mdev, false);
|
||||
if (IS_ERR(ret))
|
||||
goto out;
|
||||
list_add(&ret->list, &mdev->priv.bfregs.reg_head.list);
|
||||
out:
|
||||
mutex_unlock(&mdev->priv.bfregs.reg_head.lock);
|
||||
|
||||
|
|
Loading…
Reference in New Issue