IB/hns: Fix the bug when platform_get_resource() exec fail

This patch mainly fixes the bug with platform_get_resource().
It should return NULL when platform_get_resource() exec fail.

Signed-off-by: Lijun Ou <oulijun@huawei.com>
Reviewed-by:  Wei Hu (Xavier) <xavier.huwei@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
This commit is contained in:
Lijun Ou 2016-09-20 17:07:10 +01:00 committed by Doug Ledford
parent 1fad5fab78
commit 3e413872b1
1 changed files with 4 additions and 0 deletions

View File

@ -110,6 +110,10 @@ int hns_roce_uar_alloc(struct hns_roce_dev *hr_dev, struct hns_roce_uar *uar)
(hr_dev->caps.phy_num_uars - 1) + 1;
res = platform_get_resource(hr_dev->pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(&hr_dev->pdev->dev, "memory resource not found!\n");
return -EINVAL;
}
uar->pfn = ((res->start) >> PAGE_SHIFT) + uar->index;
return 0;