Skip to content

Commit

Permalink
CIFS: Fix ERR_PTR dereference in cifs_get_root
Browse files Browse the repository at this point in the history
move it to the beginning of the loop.

Signed-off-by: Pavel Shilovsky <piastryyy@gmail.com>
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
  • Loading branch information
Pavel Shilovsky authored and Steve French committed Sep 20, 2011
1 parent 9438fab commit 5b980b0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions fs/cifs/cifsfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,12 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb)
struct inode *dir = dentry->d_inode;
struct dentry *child;

if (!dir) {
dput(dentry);
dentry = ERR_PTR(-ENOENT);
break;
}

/* skip separators */
while (*s == sep)
s++;
Expand All @@ -563,10 +569,6 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb)
mutex_unlock(&dir->i_mutex);
dput(dentry);
dentry = child;
if (!dentry->d_inode) {
dput(dentry);
dentry = ERR_PTR(-ENOENT);
}
} while (!IS_ERR(dentry));
_FreeXid(xid);
kfree(full_path);
Expand Down

0 comments on commit 5b980b0

Please sign in to comment.