Commit a1a733f6 authored by Krishna Kumar's avatar Krishna Kumar Committed by Roland Dreier

RDMA/cma: Rewrite cma_req_handler() to encapsulate common code

Rewrite cma_req_handler error handling case to encapsulate
common code.
Signed-off-by: default avatarKrishna Kumar <krkumar2@in.ibm.com>
Acked-by: default avatarSean Hefty <sean.hefty@intel.com>
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent f115db48
...@@ -935,13 +935,8 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event) ...@@ -935,13 +935,8 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
mutex_lock(&lock); mutex_lock(&lock);
ret = cma_acquire_dev(conn_id); ret = cma_acquire_dev(conn_id);
mutex_unlock(&lock); mutex_unlock(&lock);
if (ret) { if (ret)
ret = -ENODEV; goto release_conn_id;
cma_exch(conn_id, CMA_DESTROYING);
cma_release_remove(conn_id);
rdma_destroy_id(&conn_id->id);
goto out;
}
conn_id->cm_id.ib = cm_id; conn_id->cm_id.ib = cm_id;
cm_id->context = conn_id; cm_id->context = conn_id;
...@@ -951,13 +946,17 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event) ...@@ -951,13 +946,17 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
ret = cma_notify_user(conn_id, RDMA_CM_EVENT_CONNECT_REQUEST, 0, ret = cma_notify_user(conn_id, RDMA_CM_EVENT_CONNECT_REQUEST, 0,
ib_event->private_data + offset, ib_event->private_data + offset,
IB_CM_REQ_PRIVATE_DATA_SIZE - offset); IB_CM_REQ_PRIVATE_DATA_SIZE - offset);
if (ret) { if (!ret)
goto out;
/* Destroy the CM ID by returning a non-zero value. */ /* Destroy the CM ID by returning a non-zero value. */
conn_id->cm_id.ib = NULL; conn_id->cm_id.ib = NULL;
release_conn_id:
cma_exch(conn_id, CMA_DESTROYING); cma_exch(conn_id, CMA_DESTROYING);
cma_release_remove(conn_id); cma_release_remove(conn_id);
rdma_destroy_id(&conn_id->id); rdma_destroy_id(&conn_id->id);
}
out: out:
cma_release_remove(listen_id); cma_release_remove(listen_id);
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