Skip to content

Commit f3c1f2d

Browse files
Ronnie Sahlbergjohn-cabaj
authored andcommitted
cifs: verify that tcon is valid before dereference in cifs_kill_sb
BugLink: https://bugs.launchpad.net/bugs/2036450 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]> (cherry picked from commit 8b6c584) Signed-off-by: Tim Gardner <[email protected]>
1 parent 130737b commit f3c1f2d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/cifs/cifsfs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,18 +266,18 @@ static void cifs_kill_sb(struct super_block *sb)
266266
* before we kill the sb.
267267
*/
268268
if (cifs_sb->root) {
269-
node = rb_first(root);
270-
while (node != NULL) {
269+
for (node = rb_first(root); node; node = rb_next(node)) {
271270
tlink = rb_entry(node, struct tcon_link, tl_rbnode);
272271
tcon = tlink_tcon(tlink);
272+
if (IS_ERR(tcon))
273+
continue;
273274
cfid = &tcon->crfid;
274275
mutex_lock(&cfid->fid_mutex);
275276
if (cfid->dentry) {
276277
dput(cfid->dentry);
277278
cfid->dentry = NULL;
278279
}
279280
mutex_unlock(&cfid->fid_mutex);
280-
node = rb_next(node);
281281
}
282282

283283
/* finally release root dentry */

0 commit comments

Comments
 (0)