Skip to content

Commit

Permalink
RDMA/hns: Fix usage of bitmap allocation functions return values
Browse files Browse the repository at this point in the history
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: a598c6f ("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>
  • Loading branch information
gal-pressman authored and jgunthorpe committed Aug 15, 2018
1 parent dd81b2c commit a1ceeca
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion drivers/infiniband/hw/hns/hns_roce_pd.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,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)
Expand Down
5 changes: 4 additions & 1 deletion drivers/infiniband/hw/hns/hns_roce_qp.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,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)
Expand Down

0 comments on commit a1ceeca

Please sign in to comment.