All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] RDMA/cma: Fix rdma_resolve_route memory leak
@ 2021-06-24 18:55 Gerd Rausch
  2021-06-25  5:49 ` Mark Zhang
  2021-06-25 15:03 ` Jason Gunthorpe
  0 siblings, 2 replies; 6+ messages in thread
From: Gerd Rausch @ 2021-06-24 18:55 UTC (permalink / raw)
  To: linux-rdma, linux-kernel, Doug Ledford, Jason Gunthorpe

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

Signed-off-by: Gerd Rausch <gerd.rausch@oracle.com>
---
 drivers/infiniband/core/cma.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index ab148a696c0c..4a76d5b4163e 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -2819,7 +2819,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;
-- 
2.24.1


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

end of thread, other threads:[~2021-06-25 16:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-24 18:55 [PATCH 1/1] RDMA/cma: Fix rdma_resolve_route memory leak Gerd Rausch
2021-06-25  5:49 ` Mark Zhang
2021-06-25  8:15   ` Haakon Bugge
2021-06-25 16:27   ` Gerd Rausch
2021-06-25 15:03 ` Jason Gunthorpe
2021-06-25 16:27   ` Gerd Rausch

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.