]> git.openfabrics.org - ~shefty/librdmacm.git/commitdiff
librdmacm: Fix verbs leak due to reentrancy issue
authorshamir rabinovitch <shamir.rabinovitch@oracle.com>
Wed, 30 Apr 2014 02:57:36 +0000 (19:57 -0700)
committerSean Hefty <sean.hefty@intel.com>
Wed, 30 Apr 2014 02:57:36 +0000 (19:57 -0700)
Any call to ucma_init_device must be done under lock.

Signed-off-by: Shamir Rabinovitch <shamir.rabinovitch@oracle.com>
Signed-off-by: Sean Hefty <sean.hefty@intel.com>
src/cma.c

index 4fa41ff861d6712406de906535a3830e5016ffa7..bedc95f1bed73869d3e04875706f4e618ef80141 100644 (file)
--- a/src/cma.c
+++ b/src/cma.c
@@ -416,10 +416,10 @@ static int ucma_get_device(struct cma_id_private *id_priv, uint64_t guid)
 
        return ERR(ENODEV);
 match:
+       pthread_mutex_lock(&mut);
        if ((ret = ucma_init_device(cma_dev)))
-               return ret;
+               goto out;
 
-       pthread_mutex_lock(&mut);
        if (!cma_dev->refcnt++) {
                cma_dev->pd = ibv_alloc_pd(cma_dev->verbs);
                if (!cma_dev->pd) {