diff --git a/iscsi-scst/kernel/isert-scst/iser.h b/iscsi-scst/kernel/isert-scst/iser.h index eeb8040fc..501fcf7d0 100644 --- a/iscsi-scst/kernel/isert-scst/iser.h +++ b/iscsi-scst/kernel/isert-scst/iser.h @@ -160,6 +160,7 @@ struct isert_cq { #define ISERT_DRAIN_POSTED 1 #define ISERT_DRAIN_FAILED 2 #define ISERT_DISCON_CALLED 3 +#define ISERT_CONNECTION_EST 4 struct isert_connection { struct iscsi_conn iscsi ____cacheline_aligned; diff --git a/iscsi-scst/kernel/isert-scst/iser_rdma.c b/iscsi-scst/kernel/isert-scst/iser_rdma.c index c856f15d5..d78e2e08b 100644 --- a/iscsi-scst/kernel/isert-scst/iser_rdma.c +++ b/iscsi-scst/kernel/isert-scst/iser_rdma.c @@ -599,7 +599,10 @@ static void isert_conn_closed_do_work(struct work_struct *work) if (!test_and_set_bit(ISERT_DISCON_CALLED, &isert_conn->flags)) isert_connection_closed(&isert_conn->iscsi); - isert_conn_free(isert_conn); + /* if connection established we have another refcount */ + if (test_bit(ISERT_CONNECTION_EST, &isert_conn->flags)) { + isert_conn_free(isert_conn); + } } static void isert_sched_conn_closed(struct isert_connection *isert_conn) @@ -1480,6 +1483,8 @@ static int isert_cm_connect_handler(struct rdma_cm_id *cm_id, goto out; } + set_bit(ISERT_CONNECTION_EST, &isert_conn->flags); + if (push_saved_pdu) { pr_info("iser push saved rx pdu\n"); isert_recv_completion_handler(isert_conn->saved_wr);