Skip to content

Commit

Permalink
Unify exits in O_CREAT handling
Browse files Browse the repository at this point in the history
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Mar 5, 2010
1 parent 9e67f36 commit 10fa8e6
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1821,9 +1821,8 @@ struct file *do_filp_open(int dfd, const char *pathname,
nd.flags |= LOOKUP_REVAL;
error = path_walk(pathname, &nd);
if (error) {
if (nd.root.mnt)
path_put(&nd.root);
return ERR_PTR(error);
filp = ERR_PTR(error);
goto out;
}
if (unlikely(!audit_dummy_context()))
audit_inode(pathname, nd.path.dentry);
Expand All @@ -1847,19 +1846,23 @@ struct file *do_filp_open(int dfd, const char *pathname,
filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname);
if (!filp)
goto do_link;
if (nd.root.mnt)
path_put(&nd.root);
return filp;
goto out;

exit_dput:
path_put_conditional(&path, &nd);
if (!IS_ERR(nd.intent.open.file))
release_open_intent(&nd);
exit_parent:
path_put(&nd.path);
filp = ERR_PTR(error);
out:
if (nd.root.mnt)
path_put(&nd.root);
return ERR_PTR(error);
if (filp == ERR_PTR(-ESTALE) && !force_reval) {
force_reval = 1;
goto reval;
}
return filp;

do_link:
error = -ELOOP;
Expand Down Expand Up @@ -1887,23 +1890,16 @@ 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);
if (error == -ESTALE && !force_reval) {
force_reval = 1;
goto reval;
}
return ERR_PTR(error);
filp = ERR_PTR(error);
goto out;
}
nd.flags &= ~LOOKUP_PARENT;
filp = do_last(&nd, &path, open_flag, acc_mode, mode, pathname);
if (nd.last_type == LAST_NORM)
__putname(nd.last.name);
if (!filp)
goto do_link;
if (nd.root.mnt)
path_put(&nd.root);
return filp;
goto out;
}

/**
Expand Down

0 comments on commit 10fa8e6

Please sign in to comment.