From: Junxian Huang huangjunxian6@hisilicon.com
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I9SI44
---------------------------------------------------------------------- DCA mem size from userspace should be aligned to HNS_HW_PAGE_SIZE as the DCA buffer is managed in the form of pages. Otherwise it may lead to a mis-calculation of pages, which is basically dividing the size by HNS_HW_PAGE_SIZE. Besides, zero size is invalid since it will lead to the failure of page allocation in ib_umem_get().
Fixes: f44a2f97d82a ("RDMA/hns: Introduce DCA for RC QP") Signed-off-by: Junxian Huang huangjunxian6@hisilicon.com Signed-off-by: Guofeng Yue yueguofeng@h-partners.com --- drivers/infiniband/hw/hns/hns_roce_dca.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/drivers/infiniband/hw/hns/hns_roce_dca.c b/drivers/infiniband/hw/hns/hns_roce_dca.c index e88603c96ae4..ddc21f10b923 100644 --- a/drivers/infiniband/hw/hns/hns_roce_dca.c +++ b/drivers/infiniband/hw/hns/hns_roce_dca.c @@ -1529,6 +1529,11 @@ static int UVERBS_HANDLER(HNS_IB_METHOD_DCA_MEM_REG)( if (ret) return ret;
+ if (!init_attr.size) + return -EINVAL; + + init_attr.size = hr_hw_page_align(init_attr.size); + mem = alloc_dca_mem(to_hr_dca_ctx(hr_dev, uctx)); if (!mem) return -ENOMEM;