Skip to content

Commit

Permalink
vfs: fix nd->root leak in do_filp_open()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
J. R. Okajima authored and Al Viro committed Jun 24, 2009
1 parent b5450d9 commit 654f562
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1698,8 +1698,11 @@ struct file *do_filp_open(int dfd, const char *pathname,
if (error)
return ERR_PTR(error);
error = path_walk(pathname, &nd);
if (error)
if (error) {
if (nd.root.mnt)
path_put(&nd.root);
return ERR_PTR(error);
}
if (unlikely(!audit_dummy_context()))
audit_inode(pathname, nd.path.dentry);

Expand Down Expand Up @@ -1759,6 +1762,8 @@ struct file *do_filp_open(int dfd, const char *pathname,
}
filp = nameidata_to_filp(&nd, open_flag);
mnt_drop_write(nd.path.mnt);
if (nd.root.mnt)
path_put(&nd.root);
return filp;
}

Expand Down Expand Up @@ -1819,6 +1824,8 @@ struct file *do_filp_open(int dfd, const char *pathname,
*/
if (will_write)
mnt_drop_write(nd.path.mnt);
if (nd.root.mnt)
path_put(&nd.root);
return filp;

exit_mutex_unlock:
Expand Down Expand Up @@ -1859,6 +1866,8 @@ struct file *do_filp_open(int dfd, const char *pathname,
* with "intent.open".
*/
release_open_intent(&nd);
if (nd.root.mnt)
path_put(&nd.root);
return ERR_PTR(error);
}
nd.flags &= ~LOOKUP_PARENT;
Expand Down

0 comments on commit 654f562

Please sign in to comment.