aboutsummaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2012-05-21 17:30:18 +0200
committerAl Viro <viro@zeniv.linux.org.uk>2012-06-01 12:12:01 -0400
commit50ee93afcaa970620d1fb5a9894109a2ab152868 (patch)
tree40aa31801f8b60f9f67ba168e438d4c947d502b3 /fs
parent91daee988db38b0207eec719a3160b163c077007 (diff)
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: Miklos Szeredi <mszeredi@suse.cz> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/open.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/open.c b/fs/open.c
index 9fd34b76b95..d6c79a0dffc 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -824,10 +824,11 @@ struct file *nameidata_to_filp(struct nameidata *nd)
/* Pick up the filp from the open intent */
filp = nd->intent.open.file;
- nd->intent.open.file = NULL;
/* 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;
path_get(&nd->path);
@@ -836,6 +837,7 @@ struct file *nameidata_to_filp(struct nameidata *nd)
if (!IS_ERR(res)) {
int error;
+ nd->intent.open.file = NULL;
BUG_ON(res != filp);
error = open_check_o_direct(filp);
@@ -844,7 +846,7 @@ struct file *nameidata_to_filp(struct nameidata *nd)
filp = ERR_PTR(error);
}
} else {
- put_filp(filp);
+ /* Allow nd->intent.open.file to be recycled */
filp = res;
}
}