summaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/hns/hns_roce_pd.c
diff options
context:
space:
mode:
authorLijun Ou2016-09-20 18:07:10 +0200
committerDoug Ledford2016-10-03 17:43:15 +0200
commit3e413872b1832e1cf6de037ec01b2c4c992f0136 (patch)
tree9df4ad7ef5c676ceda83b5074fe3c6b3c740b8f5 /drivers/infiniband/hw/hns/hns_roce_pd.c
parentIB/hns: Update the rq head when modify qp state (diff)
downloadkernel-qcow2-linux-3e413872b1832e1cf6de037ec01b2c4c992f0136.tar.gz
kernel-qcow2-linux-3e413872b1832e1cf6de037ec01b2c4c992f0136.tar.xz
kernel-qcow2-linux-3e413872b1832e1cf6de037ec01b2c4c992f0136.zip
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>
Diffstat (limited to 'drivers/infiniband/hw/hns/hns_roce_pd.c')
-rw-r--r--drivers/infiniband/hw/hns/hns_roce_pd.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/infiniband/hw/hns/hns_roce_pd.c b/drivers/infiniband/hw/hns/hns_roce_pd.c
index 0cd6132b75f0..05db7d59812a 100644
--- a/drivers/infiniband/hw/hns/hns_roce_pd.c
+++ b/drivers/infiniband/hw/hns/hns_roce_pd.c
@@ -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;