Skip to content

Commit 4a579da

Browse files
Sagi GrimbergNicholas Bellinger
Sagi Grimberg
authored and
Nicholas Bellinger
committed
iser-target: Fix possible deadlock in RDMA_CM connection error
Before we reach to connection established we may get an error event. In this case the core won't teardown this connection (never established it), so we take care of freeing it ourselves. Signed-off-by: Sagi Grimberg <[email protected]> Cc: <[email protected]> # v3.10+ Signed-off-by: Nicholas Bellinger <[email protected]>
1 parent 364189f commit 4a579da

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

drivers/infiniband/ulp/isert/ib_isert.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ isert_alloc_rx_descriptors(struct isert_conn *isert_conn)
222222
static void
223223
isert_free_rx_descriptors(struct isert_conn *isert_conn)
224224
{
225-
struct ib_device *ib_dev = isert_conn->conn_cm_id->device;
225+
struct ib_device *ib_dev = isert_conn->conn_device->ib_device;
226226
struct iser_rx_desc *rx_desc;
227227
int i;
228228

@@ -719,16 +719,17 @@ isert_connect_request(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
719719
static void
720720
isert_connect_release(struct isert_conn *isert_conn)
721721
{
722-
struct ib_device *ib_dev = isert_conn->conn_cm_id->device;
723722
struct isert_device *device = isert_conn->conn_device;
723+
struct ib_device *ib_dev = device->ib_device;
724724

725725
isert_dbg("conn %p\n", isert_conn);
726726

727727
if (device && device->use_fastreg)
728728
isert_conn_free_fastreg_pool(isert_conn);
729729

730730
isert_free_rx_descriptors(isert_conn);
731-
rdma_destroy_id(isert_conn->conn_cm_id);
731+
if (isert_conn->conn_cm_id)
732+
rdma_destroy_id(isert_conn->conn_cm_id);
732733

733734
if (isert_conn->conn_qp) {
734735
struct isert_comp *comp = isert_conn->conn_qp->recv_cq->cq_context;
@@ -878,12 +879,15 @@ isert_disconnected_handler(struct rdma_cm_id *cma_id,
878879
return 0;
879880
}
880881

881-
static void
882+
static int
882883
isert_connect_error(struct rdma_cm_id *cma_id)
883884
{
884885
struct isert_conn *isert_conn = cma_id->qp->qp_context;
885886

887+
isert_conn->conn_cm_id = NULL;
886888
isert_put_conn(isert_conn);
889+
890+
return -1;
887891
}
888892

889893
static int
@@ -912,7 +916,7 @@ isert_cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
912916
case RDMA_CM_EVENT_REJECTED: /* FALLTHRU */
913917
case RDMA_CM_EVENT_UNREACHABLE: /* FALLTHRU */
914918
case RDMA_CM_EVENT_CONNECT_ERROR:
915-
isert_connect_error(cma_id);
919+
ret = isert_connect_error(cma_id);
916920
break;
917921
default:
918922
isert_err("Unhandled RDMA CMA event: %d\n", event->event);

0 commit comments

Comments
 (0)