Commit 654f562c authored by J. R. Okajima's avatar J. R. Okajima Committed by Al Viro

vfs: fix nd->root leak in do_filp_open()

commit 2a737871 "Cache root in nameidata"
introduced a new member nd->root, but forgot to put it in do_filp_open().
Signed-off-by: default avatarJ. R. Okajima <hooanon05@yahoo.co.jp>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent b5450d9c
...@@ -1698,8 +1698,11 @@ struct file *do_filp_open(int dfd, const char *pathname, ...@@ -1698,8 +1698,11 @@ struct file *do_filp_open(int dfd, const char *pathname,
if (error) if (error)
return ERR_PTR(error); return ERR_PTR(error);
error = path_walk(pathname, &nd); error = path_walk(pathname, &nd);
if (error) if (error) {
if (nd.root.mnt)
path_put(&nd.root);
return ERR_PTR(error); return ERR_PTR(error);
}
if (unlikely(!audit_dummy_context())) if (unlikely(!audit_dummy_context()))
audit_inode(pathname, nd.path.dentry); audit_inode(pathname, nd.path.dentry);
...@@ -1759,6 +1762,8 @@ do_last: ...@@ -1759,6 +1762,8 @@ do_last:
} }
filp = nameidata_to_filp(&nd, open_flag); filp = nameidata_to_filp(&nd, open_flag);
mnt_drop_write(nd.path.mnt); mnt_drop_write(nd.path.mnt);
if (nd.root.mnt)
path_put(&nd.root);
return filp; return filp;
} }
...@@ -1819,6 +1824,8 @@ ok: ...@@ -1819,6 +1824,8 @@ ok:
*/ */
if (will_write) if (will_write)
mnt_drop_write(nd.path.mnt); mnt_drop_write(nd.path.mnt);
if (nd.root.mnt)
path_put(&nd.root);
return filp; return filp;
exit_mutex_unlock: exit_mutex_unlock:
...@@ -1859,6 +1866,8 @@ do_link: ...@@ -1859,6 +1866,8 @@ do_link:
* with "intent.open". * with "intent.open".
*/ */
release_open_intent(&nd); release_open_intent(&nd);
if (nd.root.mnt)
path_put(&nd.root);
return ERR_PTR(error); return ERR_PTR(error);
} }
nd.flags &= ~LOOKUP_PARENT; nd.flags &= ~LOOKUP_PARENT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment