summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorRonnie Sahlberg <lsahlber@redhat.com>2022-04-13 03:02:17 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-04-20 10:34:19 +0300
commit7a509a9f2bb7b7edce6e26242fceaf0d212369f9 (patch)
treecff692f5603cb346e2e15acc1431161e73d43691 /fs
parentbd17422b9b675414d0f1a5e070d42fe85b785cd6 (diff)
downloadlinux-7a509a9f2bb7b7edce6e26242fceaf0d212369f9.tar.xz
cifs: verify that tcon is valid before dereference in cifs_kill_sb
commit 8b6c58458ee3206dde345fce327a4cb83e69caf9 upstream. 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 <lsahlber@redhat.com> Cc: stable@vger.kernel.org Reviewed-by: Shyam Prasad N <sprasad@microsoft.com> Reported-by: Xiaoli Feng <xifeng@redhat.com> Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/cifs/cifsfs.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 92fd1a7e83dc..29a019cf1d5f 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -266,10 +266,11 @@ 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) {
@@ -277,7 +278,6 @@ static void cifs_kill_sb(struct super_block *sb)
cfid->dentry = NULL;
}
mutex_unlock(&cfid->fid_mutex);
- node = rb_next(node);
}
/* finally release root dentry */