[IPoIB] Rename ipoib_create_qp() -> ipoib_init_qp() and fix error cleanup
authorRoland Dreier <rolandd@cisco.com>
Tue, 11 Oct 2005 18:08:24 +0000 (11:08 -0700)
committerRoland Dreier <rolandd@cisco.com>
Mon, 17 Oct 2005 22:20:29 +0000 (15:20 -0700)
ipoib_create_qp() no longer creates IPoIB's QP, so it shouldn't
destroy the QP on failure -- that unwinding happens elsewhere, so the
current code can cause a double free.  While we're at it, the
function's name should match what it actually does, so rename it to
ipoib_init_qp().

Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/ulp/ipoib/ipoib.h
drivers/infiniband/ulp/ipoib/ipoib_ib.c
drivers/infiniband/ulp/ipoib/ipoib_verbs.c

index 4ea1c1c..6b14bd1 100644 (file)
@@ -277,7 +277,7 @@ int ipoib_mcast_attach(struct net_device *dev, u16 mlid,
 int ipoib_mcast_detach(struct net_device *dev, u16 mlid,
                       union ib_gid *mgid);
 
-int ipoib_qp_create(struct net_device *dev);
+int ipoib_init_qp(struct net_device *dev);
 int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca);
 void ipoib_transport_dev_cleanup(struct net_device *dev);
 
index f744009..02d0e00 100644 (file)
@@ -387,9 +387,9 @@ int ipoib_ib_dev_open(struct net_device *dev)
        struct ipoib_dev_priv *priv = netdev_priv(dev);
        int ret;
 
-       ret = ipoib_qp_create(dev);
+       ret = ipoib_init_qp(dev);
        if (ret) {
-               ipoib_warn(priv, "ipoib_qp_create returned %d\n", ret);
+               ipoib_warn(priv, "ipoib_init_qp returned %d\n", ret);
                return -1;
        }
 
index 79f59d0..b5902a7 100644 (file)
@@ -92,7 +92,7 @@ int ipoib_mcast_detach(struct net_device *dev, u16 mlid, union ib_gid *mgid)
        return ret;
 }
 
-int ipoib_qp_create(struct net_device *dev)
+int ipoib_init_qp(struct net_device *dev)
 {
        struct ipoib_dev_priv *priv = netdev_priv(dev);
        int ret;
@@ -149,10 +149,11 @@ int ipoib_qp_create(struct net_device *dev)
        return 0;
 
 out_fail:
-       ib_destroy_qp(priv->qp);
-       priv->qp = NULL;
+       qp_attr.qp_state = IB_QPS_RESET;
+       if (ib_modify_qp(priv->qp, &qp_attr, IB_QP_STATE))
+               ipoib_warn(priv, "Failed to modify QP to RESET state\n");
 
-       return -EINVAL;
+       return ret;
 }
 
 int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca)