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 <israelr@mellanox.com>


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6879 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2016-04-26 14:13:33 +00:00
parent 07bc4bb1af
commit 76b20c76b8

View File

@@ -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,