Skip to content

Commit 9660dcb

Browse files
niklas88jgunthorpe
authored andcommitted
RDMA/mlx5: Fix number of allocated XLT entries
In commit 8010d74 ("RDMA/mlx5: Split the WR setup out of mlx5_ib_update_xlt()") the allocation logic was split out of mlx5_ib_update_xlt() and the logic was changed to enable better OOM handling. Sadly this change introduced a miscalculation of the number of entries that were actually allocated when under memory pressure where it can actually become 0 which on s390 lets dma_map_single() fail. It can also lead to corruption of the free pages list when the wrong number of entries is used in the calculation of sg->length which is used as argument for free_pages(). Fix this by using the allocation size instead of misusing get_order(size). Cc: [email protected] Fixes: 8010d74 ("RDMA/mlx5: Split the WR setup out of mlx5_ib_update_xlt()") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Niklas Schnelle <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 6a21743 commit 9660dcb

File tree

1 file changed

+1
-1
lines changed
  • drivers/infiniband/hw/mlx5

1 file changed

+1
-1
lines changed

drivers/infiniband/hw/mlx5/mr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ static void *mlx5_ib_alloc_xlt(size_t *nents, size_t ent_size, gfp_t gfp_mask)
10241024

10251025
if (size > MLX5_SPARE_UMR_CHUNK) {
10261026
size = MLX5_SPARE_UMR_CHUNK;
1027-
*nents = get_order(size) / ent_size;
1027+
*nents = size / ent_size;
10281028
res = (void *)__get_free_pages(gfp_mask | __GFP_NOWARN,
10291029
get_order(size));
10301030
if (res)

0 commit comments

Comments
 (0)