Commit 72f36be0 authored by Eran Ben Elisha's avatar Eran Ben Elisha Committed by Saeed Mahameed

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: 59211bd3 ("net/mlx5: Split the load/unload flow into hardware and software flows")
Signed-off-by: default avatarEran Ben Elisha <eranbe@mellanox.com>
Signed-off-by: default avatarEugenia Emantayev <eugenia@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent b6908c29
...@@ -4160,7 +4160,7 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev) ...@@ -4160,7 +4160,7 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
goto err_cnt; goto err_cnt;
dev->mdev->priv.uar = mlx5_get_uars_page(dev->mdev); 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; goto err_cong;
err = mlx5_alloc_bfreg(dev->mdev, &dev->bfreg, false, false); 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, ...@@ -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); 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"); dev_err(&pdev->dev, "Failed allocating uar, aborting\n");
err = PTR_ERR(dev->priv.uar);
goto err_disable_msix; goto err_disable_msix;
} }
......
...@@ -168,18 +168,16 @@ struct mlx5_uars_page *mlx5_get_uars_page(struct mlx5_core_dev *mdev) ...@@ -168,18 +168,16 @@ struct mlx5_uars_page *mlx5_get_uars_page(struct mlx5_core_dev *mdev)
struct mlx5_uars_page *ret; struct mlx5_uars_page *ret;
mutex_lock(&mdev->priv.bfregs.reg_head.lock); mutex_lock(&mdev->priv.bfregs.reg_head.lock);
if (list_empty(&mdev->priv.bfregs.reg_head.list)) { 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 {
ret = list_first_entry(&mdev->priv.bfregs.reg_head.list, ret = list_first_entry(&mdev->priv.bfregs.reg_head.list,
struct mlx5_uars_page, list); struct mlx5_uars_page, list);
kref_get(&ret->ref_count); 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: out:
mutex_unlock(&mdev->priv.bfregs.reg_head.lock); mutex_unlock(&mdev->priv.bfregs.reg_head.lock);
......
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