From: Jubin John Date: Fri, 26 Feb 2016 21:33:08 +0000 (-0800) Subject: IB/rdmavt: Check lkey_table_size value before use X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ade302405f333af834c5a272f905000810adf474;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git IB/rdmavt: Check lkey_table_size value before use The lkey_table_size driver specific parameter value is used before its value is sanity checked and restricted to RVT_MAX_LKEY_TABLE_BITS. This causes a vmalloc allocation failure for large values. Fix this by moving the value check before the first usage of the value. Reviewed-by: Dennis Dalessandro Reviewed-by: Mike Marciniszyn Signed-off-by: Jubin John Signed-off-by: Doug Ledford --- diff --git a/drivers/infiniband/sw/rdmavt/mr.c b/drivers/infiniband/sw/rdmavt/mr.c index 4d5ef73e7291..0ff765bfd619 100644 --- a/drivers/infiniband/sw/rdmavt/mr.c +++ b/drivers/infiniband/sw/rdmavt/mr.c @@ -76,8 +76,6 @@ int rvt_driver_mr_init(struct rvt_dev_info *rdi) spin_lock_init(&rdi->lkey_table.lock); - rdi->lkey_table.max = 1 << lkey_table_size; - /* ensure generation is at least 4 bits */ if (lkey_table_size > RVT_MAX_LKEY_TABLE_BITS) { rvt_pr_warn(rdi, "lkey bits %u too large, reduced to %u\n", @@ -85,6 +83,7 @@ int rvt_driver_mr_init(struct rvt_dev_info *rdi) rdi->dparms.lkey_table_size = RVT_MAX_LKEY_TABLE_BITS; lkey_table_size = rdi->dparms.lkey_table_size; } + rdi->lkey_table.max = 1 << lkey_table_size; lk_tab_size = rdi->lkey_table.max * sizeof(*rdi->lkey_table.table); rdi->lkey_table.table = (struct rvt_mregion __rcu **) vmalloc_node(lk_tab_size, rdi->dparms.node);