Skip to content

Commit 2990f22

Browse files
Yuuoniyjgunthorpe
authored andcommitted
RDMA/cm: Fix memory leak in ib_cm_insert_listen
cm_alloc_id_priv() allocates resource for the cm_id_priv. When cm_init_listen() fails it doesn't free it, leading to memory leak. Add the missing error unwind. Fixes: 98f6715 ("RDMA/cm: Simplify establishing a listen cm_id") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miaoqian Lin <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 118f767 commit 2990f22

File tree

1 file changed

+3
-1
lines changed
  • drivers/infiniband/core

1 file changed

+3
-1
lines changed

drivers/infiniband/core/cm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,8 +1252,10 @@ struct ib_cm_id *ib_cm_insert_listen(struct ib_device *device,
12521252
return ERR_CAST(cm_id_priv);
12531253

12541254
err = cm_init_listen(cm_id_priv, service_id, 0);
1255-
if (err)
1255+
if (err) {
1256+
ib_destroy_cm_id(&cm_id_priv->id);
12561257
return ERR_PTR(err);
1258+
}
12571259

12581260
spin_lock_irq(&cm_id_priv->lock);
12591261
listen_id_priv = cm_insert_listen(cm_id_priv, cm_handler);

0 commit comments

Comments
 (0)