[PATCH] RDMA/mlx5: Return ENOMEM when allocating a MEMIC operation fails

From: Zhu Jun

Date: Wed Nov 11 2026 - 21:38:31 EST


When a MEMIC operation is not already mapped, map_existing_op() leaves
err set to -ENOENT. If allocating the new operation entry then fails, the
handler returns that stale lookup error instead of -ENOMEM.

Set err to -ENOMEM before allocating the operation entry.

OpenAI Codex assisted with analysis and patch preparation.

Fixes: cea85fa5dbc2 ("RDMA/mlx5: Add support in MEMIC operations")
Signed-off-by: Zhu Jun <zhujun2@xxxxxxxxxxxxxxxxxxxx>
---
drivers/infiniband/hw/mlx5/dm.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/infiniband/hw/mlx5/dm.c b/drivers/infiniband/hw/mlx5/dm.c
index 7a6fe4fea3e2..61727118d1b4 100644
--- a/drivers/infiniband/hw/mlx5/dm.c
+++ b/drivers/infiniband/hw/mlx5/dm.c
@@ -228,6 +228,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DM_MAP_OP_ADDR)(
if (!err || err != -ENOENT)
goto err_unlock;

+ err = -ENOMEM;
op_entry = kzalloc_obj(*op_entry);
if (!op_entry)
goto err_unlock;
--
2.51.0