aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
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 9fd34b76b959..d6c79a0dffc7 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -824,10 +824,11 @@ struct file *nameidata_to_filp(struct nameidata *nd)
824 824
825 /* Pick up the filp from the open intent */ 825 /* Pick up the filp from the open intent */
826 filp = nd->intent.open.file; 826 filp = nd->intent.open.file;
827 nd->intent.open.file = NULL;
828 827
829 /* Has the filesystem initialised the file for us? */ 828 /* Has the filesystem initialised the file for us? */
830 if (filp->f_path.dentry == NULL) { 829 if (filp->f_path.dentry != NULL) {
830 nd->intent.open.file = NULL;
831 } else {
831 struct file *res; 832 struct file *res;
832 833
833 path_get(&nd->path); 834 path_get(&nd->path);
@@ -836,6 +837,7 @@ struct file *nameidata_to_filp(struct nameidata *nd)
836 if (!IS_ERR(res)) { 837 if (!IS_ERR(res)) {
837 int error; 838 int error;
838 839
840 nd->intent.open.file = NULL;
839 BUG_ON(res != filp); 841 BUG_ON(res != filp);
840 842
841 error = open_check_o_direct(filp); 843 error = open_check_o_direct(filp);
@@ -844,7 +846,7 @@ struct file *nameidata_to_filp(struct nameidata *nd)
844 filp = ERR_PTR(error); 846 filp = ERR_PTR(error);
845 } 847 }
846 } else { 848 } else {
847 put_filp(filp); 849 /* Allow nd->intent.open.file to be recycled */
848 filp = res; 850 filp = res;
849 } 851 }
850 } 852 }