Skip to content

Commit 1b9ab6b

Browse files
darkrain42gregkh
authored andcommitted
smb: Initialize cfid->tcon before performing network ops
[ Upstream commit c353ee4 ] 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: ebe98f1 ("cifs: enable caching of directories for which a lease is held") Signed-off-by: Paul Aurich <[email protected]> Signed-off-by: Steve French <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 34d321f commit 1b9ab6b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

fs/smb/client/cached_dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
227227
}
228228
}
229229
cfid->dentry = dentry;
230+
cfid->tcon = tcon;
230231

231232
/*
232233
* We do not hold the lock for the open because in case
@@ -298,7 +299,6 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
298299
}
299300
goto oshr_free;
300301
}
301-
cfid->tcon = tcon;
302302
cfid->is_open = true;
303303

304304
spin_lock(&cfids->cfid_list_lock);

0 commit comments

Comments
 (0)