RDMA/hns: Clean up the return value check of hns_roce_alloc_cmd_mailbox()
authorWenpeng Liang <liangwenpeng@huawei.com>
Wed, 2 Mar 2022 06:48:28 +0000 (14:48 +0800)
committerJason Gunthorpe <jgg@nvidia.com>
Fri, 4 Mar 2022 21:36:32 +0000 (17:36 -0400)
hns_roce_alloc_cmd_mailbox() never returns NULL, so the check should be
IS_ERR(). And the error code should be converted as the function's return
value.

Link: https://lore.kernel.org/r/20220302064830.61706-8-liangwenpeng@huawei.com
Signed-off-by: Wenpeng Liang <liangwenpeng@huawei.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/hw/hns/hns_roce_hw_v2.c
drivers/infiniband/hw/hns/hns_roce_mr.c
drivers/infiniband/hw/hns/hns_roce_srq.c

index 631f6e2334928259c202d54bff4a729daaa2d04a..06eb4f00428c358fa0aacd47859de90b1c9fb9fb 100644 (file)
@@ -5981,8 +5981,8 @@ static int hns_roce_v2_create_eq(struct hns_roce_dev *hr_dev,
 
        /* Allocate mailbox memory */
        mailbox = hns_roce_alloc_cmd_mailbox(hr_dev);
-       if (IS_ERR_OR_NULL(mailbox))
-               return -ENOMEM;
+       if (IS_ERR(mailbox))
+               return PTR_ERR(mailbox);
 
        ret = alloc_eq_buf(hr_dev, eq);
        if (ret)
index 39de862666d757ae1b65cd55b507c1f0914c61d0..b58b869339ccd6f71691c68709ad64e953b7929f 100644 (file)
@@ -148,10 +148,8 @@ static int hns_roce_mr_enable(struct hns_roce_dev *hr_dev,
 
        /* Allocate mailbox memory */
        mailbox = hns_roce_alloc_cmd_mailbox(hr_dev);
-       if (IS_ERR(mailbox)) {
-               ret = PTR_ERR(mailbox);
-               return ret;
-       }
+       if (IS_ERR(mailbox))
+               return PTR_ERR(mailbox);
 
        if (mr->type != MR_TYPE_FRMR)
                ret = hr_dev->hw->write_mtpt(hr_dev, mailbox->buf, mr);
index e316276e18c22d7551ef31ee25470ad9a1d6fd34..97032a357b000cc3bfcb531196f0e1247f463077 100644 (file)
@@ -89,9 +89,9 @@ static int alloc_srqc(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq)
        }
 
        mailbox = hns_roce_alloc_cmd_mailbox(hr_dev);
-       if (IS_ERR_OR_NULL(mailbox)) {
+       if (IS_ERR(mailbox)) {
                ibdev_err(ibdev, "failed to alloc mailbox for SRQC.\n");
-               ret = -ENOMEM;
+               ret = PTR_ERR(mailbox);
                goto err_xa;
        }