]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
smb: Initialize cfid->tcon before performing network ops
authorPaul Aurich <paul@darkrain42.org>
Wed, 27 Nov 2024 00:50:31 +0000 (18:50 -0600)
committerSteve French <stfrench@microsoft.com>
Wed, 27 Nov 2024 05:35:34 +0000 (23:35 -0600)
Avoid leaking a tcon ref when a lease break races with opening the
cached directory. Processing the leak break might take a reference to
the tcon in cached_dir_lease_break() and then fail to release the ref in
cached_dir_offload_close, since cfid->tcon is still NULL.

Fixes: ebe98f1447bb ("cifs: enable caching of directories for which a lease is held")
Signed-off-by: Paul Aurich <paul@darkrain42.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/cached_dir.c

index d9e1d1dc6178bd8da912d6c9469993c167671aa8..fe738623cf1ba91ee44e23de346c60460cbc647d 100644 (file)
@@ -229,6 +229,7 @@ replay_again:
                }
        }
        cfid->dentry = dentry;
+       cfid->tcon = tcon;
 
        /*
         * We do not hold the lock for the open because in case
@@ -300,7 +301,6 @@ replay_again:
                }
                goto oshr_free;
        }
-       cfid->tcon = tcon;
        cfid->is_open = true;
 
        spin_lock(&cfids->cfid_list_lock);