Skip to content

Commit 654f562

Browse files
J. R. OkajimaAl Viro
authored andcommitted
vfs: fix nd->root leak in do_filp_open()
commit 2a73787 "Cache root in nameidata" introduced a new member nd->root, but forgot to put it in do_filp_open(). Signed-off-by: J. R. Okajima <hooanon05@yahoo.co.jp> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent b5450d9 commit 654f562

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎fs/namei.c‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1698,8 +1698,11 @@ struct file *do_filp_open(int dfd, const char *pathname,
16981698
if (error)
16991699
return ERR_PTR(error);
17001700
error = path_walk(pathname, &nd);
1701-
if (error)
1701+
if (error) {
1702+
if (nd.root.mnt)
1703+
path_put(&nd.root);
17021704
return ERR_PTR(error);
1705+
}
17031706
if (unlikely(!audit_dummy_context()))
17041707
audit_inode(pathname, nd.path.dentry);
17051708

@@ -1759,6 +1762,8 @@ struct file *do_filp_open(int dfd, const char *pathname,
17591762
}
17601763
filp = nameidata_to_filp(&nd, open_flag);
17611764
mnt_drop_write(nd.path.mnt);
1765+
if (nd.root.mnt)
1766+
path_put(&nd.root);
17621767
return filp;
17631768
}
17641769

@@ -1819,6 +1824,8 @@ struct file *do_filp_open(int dfd, const char *pathname,
18191824
*/
18201825
if (will_write)
18211826
mnt_drop_write(nd.path.mnt);
1827+
if (nd.root.mnt)
1828+
path_put(&nd.root);
18221829
return filp;
18231830

18241831
exit_mutex_unlock:
@@ -1859,6 +1866,8 @@ struct file *do_filp_open(int dfd, const char *pathname,
18591866
* with "intent.open".
18601867
*/
18611868
release_open_intent(&nd);
1869+
if (nd.root.mnt)
1870+
path_put(&nd.root);
18621871
return ERR_PTR(error);
18631872
}
18641873
nd.flags &= ~LOOKUP_PARENT;

0 commit comments

Comments
 (0)