Commit 50ee93af authored by Miklos Szeredi's avatar Miklos Szeredi Committed by Al Viro

vfs: nameidata_to_filp(): don't throw away file on error

If open fails, don't put the file.  This allows it to be reused if open needs to
be retried.
Signed-off-by: default avatarMiklos Szeredi <mszeredi@suse.cz>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 91daee98
...@@ -824,10 +824,11 @@ struct file *nameidata_to_filp(struct nameidata *nd) ...@@ -824,10 +824,11 @@ struct file *nameidata_to_filp(struct nameidata *nd)
/* Pick up the filp from the open intent */ /* Pick up the filp from the open intent */
filp = nd->intent.open.file; filp = nd->intent.open.file;
nd->intent.open.file = NULL;
/* Has the filesystem initialised the file for us? */ /* Has the filesystem initialised the file for us? */
if (filp->f_path.dentry == NULL) { if (filp->f_path.dentry != NULL) {
nd->intent.open.file = NULL;
} else {
struct file *res; struct file *res;
path_get(&nd->path); path_get(&nd->path);
...@@ -836,6 +837,7 @@ struct file *nameidata_to_filp(struct nameidata *nd) ...@@ -836,6 +837,7 @@ struct file *nameidata_to_filp(struct nameidata *nd)
if (!IS_ERR(res)) { if (!IS_ERR(res)) {
int error; int error;
nd->intent.open.file = NULL;
BUG_ON(res != filp); BUG_ON(res != filp);
error = open_check_o_direct(filp); error = open_check_o_direct(filp);
...@@ -844,7 +846,7 @@ struct file *nameidata_to_filp(struct nameidata *nd) ...@@ -844,7 +846,7 @@ struct file *nameidata_to_filp(struct nameidata *nd)
filp = ERR_PTR(error); filp = ERR_PTR(error);
} }
} else { } else {
put_filp(filp); /* Allow nd->intent.open.file to be recycled */
filp = res; filp = res;
} }
} }
......
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