]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
RDMA/rtrs: Fix clt_path::max_pages_per_mr calculation
authorHonggang LI <honggangli@163.com>
Mon, 29 Dec 2025 02:56:17 +0000 (10:56 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Jan 2026 12:09:58 +0000 (13:09 +0100)
[ Upstream commit 43bd09d5b750f700499ae8ec45fd41a4c48673e6 ]

If device max_mr_size bits in the range [mr_page_shift+31:mr_page_shift]
are zero, the `min3` function will set clt_path::max_pages_per_mr to
zero.

`alloc_path_reqs` will pass zero, which is invalid, as the third parameter
to `ib_alloc_mr`.

Fixes: 6a98d71daea1 ("RDMA/rtrs: client: main functionality")
Signed-off-by: Honggang LI <honggangli@163.com>
Link: https://patch.msgid.link/20251229025617.13241-1-honggangli@163.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/infiniband/ulp/rtrs/rtrs-clt.c

index e8f5a1f104cfad74e57fc06ed6962e78fdb5441c..cda7849e2133cd4b820b3fa99a3250c3d49ba191 100644 (file)
@@ -1469,6 +1469,7 @@ static void query_fast_reg_mode(struct rtrs_clt_path *clt_path)
        mr_page_shift      = max(12, ffs(ib_dev->attrs.page_size_cap) - 1);
        max_pages_per_mr   = ib_dev->attrs.max_mr_size;
        do_div(max_pages_per_mr, (1ull << mr_page_shift));
+       max_pages_per_mr = min_not_zero((u32)max_pages_per_mr, U32_MAX);
        clt_path->max_pages_per_mr =
                min3(clt_path->max_pages_per_mr, (u32)max_pages_per_mr,
                     ib_dev->attrs.max_fast_reg_page_list_len);