cifs: avoid potential races when handling multiple dfs tcons
[sfrench/cifs-2.6.git] / fs / cifs / connect.c
index 9451b1023af8be13bcc78dbc2316c5e0f7cf44d2..9a730efbce32867d4a264c204c2643c1c9cb0d6b 100644 (file)
@@ -2340,6 +2340,9 @@ cifs_put_tcon(struct cifs_tcon *tcon)
 
        /* cancel polling of interfaces */
        cancel_delayed_work_sync(&tcon->query_interfaces);
+#ifdef CONFIG_CIFS_DFS_UPCALL
+       cancel_delayed_work_sync(&tcon->dfs_cache_work);
+#endif
 
        if (tcon->use_witness) {
                int rc;
@@ -2587,7 +2590,9 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
                queue_delayed_work(cifsiod_wq, &tcon->query_interfaces,
                                   (SMB_INTERFACE_POLL_INTERVAL * HZ));
        }
-
+#ifdef CONFIG_CIFS_DFS_UPCALL
+       INIT_DELAYED_WORK(&tcon->dfs_cache_work, dfs_cache_refresh);
+#endif
        spin_lock(&cifs_tcp_ses_lock);
        list_add(&tcon->tcon_list, &ses->tcon_list);
        spin_unlock(&cifs_tcp_ses_lock);