Linux-RDMA Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] RMDA/cm: Fix missing ib_cm_destroy_id() in ib_cm_insert_listen()
@ 2020-02-21 15:20 Jason Gunthorpe
  2020-02-27 20:45 ` Jason Gunthorpe
  0 siblings, 1 reply; 2+ messages in thread
From: Jason Gunthorpe @ 2020-02-21 15:20 UTC (permalink / raw)
  To: linux-rdma

The algorithm pre-allocates a cm_id since allocation cannot be done while
holding the cm.lock spinlock, however it doesn't free it on one error
path, leading to a memory leak.

Fixes: 067b171b8679 ("IB/cm: Share listening CM IDs")
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
---
 drivers/infiniband/core/cm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index bfe97bae91ce0d..c8fe74f6394faa 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -1191,6 +1191,7 @@ struct ib_cm_id *ib_cm_insert_listen(struct ib_device *device,
 			/* Sharing an ib_cm_id with different handlers is not
 			 * supported */
 			spin_unlock_irqrestore(&cm.lock, flags);
+			ib_destroy_cm_id(cm_id);
 			return ERR_PTR(-EINVAL);
 		}
 		refcount_inc(&cm_id_priv->refcount);
-- 
2.25.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] RMDA/cm: Fix missing ib_cm_destroy_id() in ib_cm_insert_listen()
  2020-02-21 15:20 [PATCH] RMDA/cm: Fix missing ib_cm_destroy_id() in ib_cm_insert_listen() Jason Gunthorpe
@ 2020-02-27 20:45 ` Jason Gunthorpe
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Gunthorpe @ 2020-02-27 20:45 UTC (permalink / raw)
  To: linux-rdma

On Fri, Feb 21, 2020 at 03:20:26PM +0000, Jason Gunthorpe wrote:
> The algorithm pre-allocates a cm_id since allocation cannot be done while
> holding the cm.lock spinlock, however it doesn't free it on one error
> path, leading to a memory leak.
> 
> Fixes: 067b171b8679 ("IB/cm: Share listening CM IDs")
> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
> ---
>  drivers/infiniband/core/cm.c | 1 +
>  1 file changed, 1 insertion(+)

Applied to for-rc

Jason

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-21 15:20 [PATCH] RMDA/cm: Fix missing ib_cm_destroy_id() in ib_cm_insert_listen() Jason Gunthorpe
2020-02-27 20:45 ` Jason Gunthorpe

Linux-RDMA Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-rdma/0 linux-rdma/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rdma linux-rdma/ https://lore.kernel.org/linux-rdma \
		linux-rdma@vger.kernel.org
	public-inbox-index linux-rdma

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-rdma


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git