xprtrdma tries to destroy pd after destruction of cm_id. However,
pd should be deallocated before destruction of cm_id.

Signed-off-by: Devesh Sharma <[email protected]>
---
 net/sunrpc/xprtrdma/verbs.c |   22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
index b00e55e..096e94b 100644
--- a/net/sunrpc/xprtrdma/verbs.c
+++ b/net/sunrpc/xprtrdma/verbs.c
@@ -544,7 +544,7 @@ rpcrdma_ia_open(struct rpcrdma_xprt *xprt, struct sockaddr 
*addr, int memreg)
        if (rc) {
                dprintk("RPC:       %s: ib_query_device failed %d\n",
                        __func__, rc);
-               goto out2;
+               goto out3;
        }
 
        if (devattr.device_cap_flags & IB_DEVICE_LOCAL_DMA_LKEY) {
@@ -602,14 +602,14 @@ rpcrdma_ia_open(struct rpcrdma_xprt *xprt, struct 
sockaddr *addr, int memreg)
                                "phys register failed with %lX\n",
                                __func__, PTR_ERR(ia->ri_bind_mem));
                        rc = -ENOMEM;
-                       goto out2;
+                       goto out3;
                }
                break;
        default:
                printk(KERN_ERR "RPC: Unsupported memory "
                                "registration mode: %d\n", memreg);
                rc = -ENOMEM;
-               goto out2;
+               goto out3;
        }
        dprintk("RPC:       %s: memory registration strategy is %d\n",
                __func__, memreg);
@@ -619,6 +619,9 @@ rpcrdma_ia_open(struct rpcrdma_xprt *xprt, struct sockaddr 
*addr, int memreg)
 
        rwlock_init(&ia->ri_qplock);
        return 0;
+out3:
+       ib_dealloc_pd(ia->ri_pd);
+       ia->ri_pd = NULL;
 out2:
        module_put(ia->ri_id->device->owner);
        rdma_destroy_id(ia->ri_id);
@@ -643,19 +646,20 @@ rpcrdma_ia_close(struct rpcrdma_ia *ia)
                dprintk("RPC:       %s: ib_dereg_mr returned %i\n",
                        __func__, rc);
        }
+
        if (ia->ri_id != NULL && !IS_ERR(ia->ri_id)) {
                if (ia->ri_id->qp)
                        rdma_destroy_qp(ia->ri_id);
+
+               if (ia->ri_pd != NULL && !IS_ERR(ia->ri_pd)) {
+                       rc = ib_dealloc_pd(ia->ri_pd);
+                       dprintk("RPC:       %s: ib_dealloc_pd returned %i\n",
+                               __func__, rc);
+               }
                module_put(ia->ri_id->device->owner);
                rdma_destroy_id(ia->ri_id);
                ia->ri_id = NULL;
        }
-
-       if (ia->ri_pd != NULL && !IS_ERR(ia->ri_pd)) {
-               rc = ib_dealloc_pd(ia->ri_pd);
-               dprintk("RPC:       %s: ib_dealloc_pd returned %i\n",
-                       __func__, rc);
-       }
 }
 
 /*
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to