RDMA/hns: Fix usage of bitmap allocation functions return values
authorGal Pressman <pressmangal@gmail.com>
Thu, 9 Aug 2018 19:00:47 +0000 (22:00 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 15 Sep 2018 07:42:58 +0000 (09:42 +0200)
[ Upstream commit a1ceeca679dccc492235f0f629d9e9f7b3d51ca8 ]

hns bitmap allocation functions return 0 on success and -1 on failure.
Callers of these functions wrongly used their return value as an errno,
fix that by making a proper conversion.

Fixes: a598c6f4c5a8 ("IB/hns: Simplify function of pd alloc and qp alloc")
Signed-off-by: Gal Pressman <pressmangal@gmail.com>
Acked-by: Lijun Ou <oulijun@huawei.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/infiniband/hw/hns/hns_roce_pd.c
drivers/infiniband/hw/hns/hns_roce_qp.c

index 05db7d5..da61ce8 100644 (file)
@@ -35,7 +35,7 @@
 
 static int hns_roce_pd_alloc(struct hns_roce_dev *hr_dev, unsigned long *pdn)
 {
-       return hns_roce_bitmap_alloc(&hr_dev->pd_bitmap, pdn);
+       return hns_roce_bitmap_alloc(&hr_dev->pd_bitmap, pdn) ? -ENOMEM : 0;
 }
 
 static void hns_roce_pd_free(struct hns_roce_dev *hr_dev, unsigned long pdn)
index e86dd8d..33cf103 100644 (file)
@@ -114,7 +114,10 @@ static int hns_roce_reserve_range_qp(struct hns_roce_dev *hr_dev, int cnt,
 {
        struct hns_roce_qp_table *qp_table = &hr_dev->qp_table;
 
-       return hns_roce_bitmap_alloc_range(&qp_table->bitmap, cnt, align, base);
+       return hns_roce_bitmap_alloc_range(&qp_table->bitmap, cnt, align,
+                                          base) ?
+                      -ENOMEM :
+                      0;
 }
 
 enum hns_roce_qp_state to_hns_roce_state(enum ib_qp_state state)