Commit 5c1b7f9a authored by Junxian Huang's avatar Junxian Huang Committed by 岳国风
Browse files

RDMA/hns: Fix missing validation check of DCA mem size

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: f44a2f97 ("RDMA/hns: Introduce DCA for RC QP")
Signed-off-by: default avatarJunxian Huang <huangjunxian6@hisilicon.com>
Signed-off-by: default avatarGuofeng Yue <yueguofeng@h-partners.com>
parent ea169d67
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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;