Skip to contentSkip to conversation

RDMA/mlx5: Fix UMR XLT cleanup on ODP populate failure

PATCH Applied Prathamesh Deshpande 2 participants 2 messages Apr 26 – May 11

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 RDMA/mlx5: Fix UMR XLT cleanup on ODP populate failure

mlx5r_umr_update_xlt() allocates and DMA maps an XLT buffer with mlx5r_umr_create_xlt(). The buffer is released by the common cleanup path through mlx5r_umr_unmap_free_xlt().

After mlx5_odp_populate_xlt() became fallible, its error path returned directly and skipped that cleanup. This leaks the XLT DMA mapping and buffer. If the emergency XLT page was used, it also leaves xlt_emergency_page_mutex locked.

Break out of the loop so execution falls through the existing cleanup path.

Fixes 1efe8c0670d6 ("RDMA/core: Convert UMEM ODP DMA mapping to caching IOVA and page linkage")

---
v2:
- Use 'break' instead of 'goto' as the loop already checks 'err'. (Michael Gur)

 drivers/infiniband/hw/mlx5/umr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/umr.c +1 -1
index 29488fba21a0..71f331ce6d89 100644
@@ -915,7 +915,7 @@ int mlx5r_umr_update_xlt(struct mlx5_ib_mr *mr, u64 idx, int npages,
 		 */
 		err = mlx5_odp_populate_xlt(xlt, idx, npages, mr, flags);
 		if (err)
-			return err;
+			break;
 		dma_sync_single_for_device(ddev, sg.addr, sg.length,
 					   DMA_TO_DEVICE);
 		sg.length = ALIGN(size_to_map, MLX5_UMR_FLEX_ALIGNMENT);
Signature · 1 line
2.43.0
#1 lore raw
Quoted 10 lines · Prathamesh Deshpande

mlx5r_umr_update_xlt() allocates and DMA maps an XLT buffer with mlx5r_umr_create_xlt(). The buffer is released by the common cleanup path through mlx5r_umr_unmap_free_xlt().

After mlx5_odp_populate_xlt() became fallible, its error path returned directly and skipped that cleanup. This leaks the XLT DMA mapping and buffer. If the emergency XLT page was used, it also leaves xlt_emergency_page_mutex locked.

[...]

Applied, thanks!

[1/1] RDMA/mlx5: Fix UMR XLT cleanup on ODP populate failure

      https://git.kernel.org/rdma/rdma/c/40d05a2e003357

Best regards,

Signature · 1 line
Leon Romanovsky <[email protected]>