Skip to content

Commit

Permalink
cifs: verify that tcon is valid before dereference in cifs_kill_sb
Browse files Browse the repository at this point in the history
On umount, cifs_sb->tlink_tree might contain entries that do not represent
a valid tcon.
Check the tcon for error before we dereference it.

Signed-off-by: Ronnie Sahlberg <[email protected]>
Cc: [email protected]
Reviewed-by: Shyam Prasad N <[email protected]>
Reported-by: Xiaoli Feng <[email protected]>
Signed-off-by: Steve French <[email protected]>
  • Loading branch information
Ronnie Sahlberg authored and Steve French committed Apr 14, 2022
1 parent 64c4a37 commit 8b6c584
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fs/cifs/cifsfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,18 +266,18 @@ static void cifs_kill_sb(struct super_block *sb)
* before we kill the sb.
*/
if (cifs_sb->root) {
node = rb_first(root);
while (node != NULL) {
for (node = rb_first(root); node; node = rb_next(node)) {
tlink = rb_entry(node, struct tcon_link, tl_rbnode);
tcon = tlink_tcon(tlink);
if (IS_ERR(tcon))
continue;
cfid = &tcon->crfid;
mutex_lock(&cfid->fid_mutex);
if (cfid->dentry) {
dput(cfid->dentry);
cfid->dentry = NULL;
}
mutex_unlock(&cfid->fid_mutex);
node = rb_next(node);
}

/* finally release root dentry */
Expand Down

0 comments on commit 8b6c584

Please sign in to comment.