xprtrdma: Free the pd if ib_query_qp() fails
[pandora-kernel.git] / net / sunrpc / xprtrdma / verbs.c
index 28236ba..37e4484 100644 (file)
@@ -485,7 +485,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) {
@@ -587,7 +587,7 @@ rpcrdma_ia_open(struct rpcrdma_xprt *xprt, struct sockaddr *addr, int memreg)
                printk(KERN_ERR "%s: invalid memory registration mode %d\n",
                                __func__, memreg);
                rc = -EINVAL;
-               goto out2;
+               goto out3;
        }
        dprintk("RPC:       %s: memory registration strategy is %d\n",
                __func__, memreg);
@@ -596,6 +596,10 @@ rpcrdma_ia_open(struct rpcrdma_xprt *xprt, struct sockaddr *addr, int memreg)
        ia->ri_memreg_strategy = memreg;
 
        return 0;
+
+out3:
+       ib_dealloc_pd(ia->ri_pd);
+       ia->ri_pd = NULL;
 out2:
        rdma_destroy_id(ia->ri_id);
        ia->ri_id = NULL;