From 76b20c76b838c49aba790ff600d52de5eb4a7ba3 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 26 Apr 2016 14:13:33 +0000 Subject: [PATCH] isert: fix race between teardown flow and connect flow It is possible to get ESTABLISHED RDMACM event while the connection is already started teardown flow (i.e. addr change). At teardown the refcount is reduced to zero and we start releasing the connection. In established event We need to check conn is not in teardown flow by checking its ref count is not 0. Signed-off-by: Israel Rukshin git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6879 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/kernel/isert-scst/iser_rdma.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/iscsi-scst/kernel/isert-scst/iser_rdma.c b/iscsi-scst/kernel/isert-scst/iser_rdma.c index fe98696ec..9f50728d9 100644 --- a/iscsi-scst/kernel/isert-scst/iser_rdma.c +++ b/iscsi-scst/kernel/isert-scst/iser_rdma.c @@ -1453,7 +1453,10 @@ static int isert_cm_connect_handler(struct rdma_cm_id *cm_id, if (unlikely(ret)) goto out; - kref_get(&isert_conn->kref); + /* check if already started teardown */ + if (!unlikely(kref_get_unless_zero(&isert_conn->kref))) + goto out; + /* notify upper layer */ ret = isert_conn_established(&isert_conn->iscsi, (struct sockaddr *)&isert_conn->peer_addr,