@@ -2307,7 +2307,16 @@ static int iscsi_if_stop_conn(struct iscsi_cls_conn *conn, int flag)
*/
if (flag == STOP_CONN_TERM) {
cancel_work_sync(&conn->cleanup_work);
+
+ /* There is a race window between cancel clean_work and
+ * connection stopped. Socket down event may queue clean up
+ * work again before connection stopped which will result
+ * stop connection cocurrency issue. Avoid this issue
+ * by leveraging ep_mutex
+ */
+ mutex_lock(&conn->ep_mutex);
iscsi_stop_conn(conn, flag);
+ mutex_unlock(&conn->ep_mutex);
} else {
/*
* Figure out if it was the kernel or userspace initiating this.