public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] librdmacm: Fix verbs leak due to reentrancy issue
@ 2014-04-22 11:22 shamir rabinovitch
  2014-04-22 18:35 ` Hefty, Sean
  0 siblings, 1 reply; 4+ messages in thread
From: shamir rabinovitch @ 2014-04-22 11:22 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA

Sean,

I was out of work so I tested the patch "librdmacm: lazy initialization
for ib devices" today. The patch works fine for my test case. The only
concern I have is that I think the patch might leak verbs context. I
think that any call to ucma_init_device must be done with mutex locked.
Please correct me if I am wrong.

Thanks, Shamir


Signed-off-by: shamir rabinovitch <shamir.rabinovitch-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
---
 src/cma.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/cma.c b/src/cma.c
index 0dc229e..42769cf 100644
--- a/src/cma.c
+++ b/src/cma.c
@@ -416,10 +416,13 @@ static int ucma_get_device(struct cma_id_private *id_priv, uint64_t guid)
 
 	return ERR(ENODEV);
 match:
-	if ((ret = ucma_init_device(cma_dev)))
+	pthread_mutex_lock(&mut);
+
+	if ((ret = ucma_init_device(cma_dev))) {
+		pthread_mutex_unlock(&mut);
 		return ret;
+	}
 
-	pthread_mutex_lock(&mut);
 	if (!cma_dev->refcnt++) {
 		cma_dev->pd = ibv_alloc_pd(cma_dev->verbs);
 		if (!cma_dev->pd) {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2014-04-30  3:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-22 11:22 [PATCH] librdmacm: Fix verbs leak due to reentrancy issue shamir rabinovitch
2014-04-22 18:35 ` Hefty, Sean
     [not found]   ` <1828884A29C6694DAF28B7E6B8A82373992F2EE8-P5GAC/sN6hkd3b2yrw5b5LfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-04-29 13:48     ` Shamir Rabinovith
2014-04-30  3:14       ` Hefty, Sean

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox