Skip to content

Commit

Permalink
RDMA/cma: Fix rdma_resolve_route() memory leak
Browse files Browse the repository at this point in the history
[ Upstream commit 74f160e ]

Fix a memory leak when "mda_resolve_route() is called more than once on
the same "rdma_cm_id".

This is possible if cma_query_handler() triggers the
RDMA_CM_EVENT_ROUTE_ERROR flow which puts the state machine back and
allows rdma_resolve_route() to be called again.

Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Gerd Rausch <[email protected]>
Signed-off-by: Jason Gunthorpe <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
gerd-rausch authored and gregkh committed Jul 19, 2021
1 parent a8585fd commit 3d08b59
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/infiniband/core/cma.c
Original file line number Diff line number Diff line change
Expand Up @@ -2793,7 +2793,8 @@ static int cma_resolve_ib_route(struct rdma_id_private *id_priv,

cma_init_resolve_route_work(work, id_priv);

route->path_rec = kmalloc(sizeof *route->path_rec, GFP_KERNEL);
if (!route->path_rec)
route->path_rec = kmalloc(sizeof *route->path_rec, GFP_KERNEL);
if (!route->path_rec) {
ret = -ENOMEM;
goto err1;
Expand Down

0 comments on commit 3d08b59

Please sign in to comment.