]> git.baikalelectronics.ru Git - kernel.git/commitdiff
cifs: add missing spinlock around tcon refcount
authorPaulo Alcantara <pc@cjr.nz>
Wed, 14 Sep 2022 04:34:51 +0000 (21:34 -0700)
committerSteve French <stfrench@microsoft.com>
Wed, 14 Sep 2022 08:59:51 +0000 (03:59 -0500)
Add missing spinlock to protect updates on tcon refcount in
cifs_put_tcon().

Fixes: 252294d3f636 ("cifs: avoid use of global locks for high contention data")
Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/connect.c

index 0225f4c8adf0caa49de65ff6c4c8860c4c1d5afb..7ae6f2c08153e63b17cc19262fad12562a53cecd 100644 (file)
@@ -2345,7 +2345,9 @@ cifs_put_tcon(struct cifs_tcon *tcon)
        ses = tcon->ses;
        cifs_dbg(FYI, "%s: tc_count=%d\n", __func__, tcon->tc_count);
        spin_lock(&cifs_tcp_ses_lock);
+       spin_lock(&tcon->tc_lock);
        if (--tcon->tc_count > 0) {
+               spin_unlock(&tcon->tc_lock);
                spin_unlock(&cifs_tcp_ses_lock);
                return;
        }
@@ -2354,6 +2356,7 @@ cifs_put_tcon(struct cifs_tcon *tcon)
        WARN_ON(tcon->tc_count < 0);
 
        list_del_init(&tcon->tcon_list);
+       spin_unlock(&tcon->tc_lock);
        spin_unlock(&cifs_tcp_ses_lock);
 
        /* cancel polling of interfaces */