Commit 675a027c authored by Krishna Kumar's avatar Krishna Kumar Committed by Roland Dreier

RDMA/cma: Fix leak of cm_ids in case of failures

cma_connect_ib() and cma_connect_iw() leak cm_id's in failure cases.
Signed-off-by: default avatarKrishna Kumar <krkumar2@in.ibm.com>
Signed-off-by: default avatarSean Hefty <sean.hefty@intel.com>
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent 95f3eff6
...@@ -1862,6 +1862,11 @@ static int cma_connect_ib(struct rdma_id_private *id_priv, ...@@ -1862,6 +1862,11 @@ static int cma_connect_ib(struct rdma_id_private *id_priv,
ret = ib_send_cm_req(id_priv->cm_id.ib, &req); ret = ib_send_cm_req(id_priv->cm_id.ib, &req);
out: out:
if (ret && !IS_ERR(id_priv->cm_id.ib)) {
ib_destroy_cm_id(id_priv->cm_id.ib);
id_priv->cm_id.ib = NULL;
}
kfree(private_data); kfree(private_data);
return ret; return ret;
} }
...@@ -1889,10 +1894,8 @@ static int cma_connect_iw(struct rdma_id_private *id_priv, ...@@ -1889,10 +1894,8 @@ static int cma_connect_iw(struct rdma_id_private *id_priv,
cm_id->remote_addr = *sin; cm_id->remote_addr = *sin;
ret = cma_modify_qp_rtr(&id_priv->id); ret = cma_modify_qp_rtr(&id_priv->id);
if (ret) { if (ret)
iw_destroy_cm_id(cm_id); goto out;
return ret;
}
iw_param.ord = conn_param->initiator_depth; iw_param.ord = conn_param->initiator_depth;
iw_param.ird = conn_param->responder_resources; iw_param.ird = conn_param->responder_resources;
...@@ -1904,6 +1907,10 @@ static int cma_connect_iw(struct rdma_id_private *id_priv, ...@@ -1904,6 +1907,10 @@ static int cma_connect_iw(struct rdma_id_private *id_priv,
iw_param.qpn = conn_param->qp_num; iw_param.qpn = conn_param->qp_num;
ret = iw_cm_connect(cm_id, &iw_param); ret = iw_cm_connect(cm_id, &iw_param);
out: out:
if (ret && !IS_ERR(cm_id)) {
iw_destroy_cm_id(cm_id);
id_priv->cm_id.iw = NULL;
}
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment