net/mlx5: Fix mlx5_get_uars_page to return error code
authorEran Ben Elisha <eranbe@mellanox.com>
Mon, 20 Nov 2017 07:58:01 +0000 (09:58 +0200)
committerSaeed Mahameed <saeedm@mellanox.com>
Fri, 12 Jan 2018 00:01:47 +0000 (02:01 +0200)
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: 59211bd3b632 ("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>
drivers/infiniband/hw/mlx5/main.c
drivers/net/ethernet/mellanox/mlx5/core/main.c
drivers/net/ethernet/mellanox/mlx5/core/uar.c

index 00cb184fa027ba91733c2e145372d7f9c258ca08..262c1aa2e028aae1e9c9bd7f4a3541105faffa17 100644 (file)
@@ -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);
index a4c82fa71aec4221e0652f7b58559b76bf380cbc..6dffa58fb17873a849fcedad2ca7a3089c350a88 100644 (file)
@@ -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;
        }
 
index 222b25908d012614639b4e9ef2a8a7727a82cd18..8b97066dd1f19e1b5a3151a7e6228a86b65dcd68 100644 (file)
@@ -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);