]> Pileus Git - ~andy/linux/blobdiff - fs/open.c
Merge branch 'smp-hotplug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[~andy/linux] / fs / open.c
index 9fd34b76b9593bd0b3a2b280a8481f79215fabda..1540632d8387fe98a51d0193201346acb18ae70e 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -397,10 +397,10 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
 {
        struct file *file;
        struct inode *inode;
-       int error;
+       int error, fput_needed;
 
        error = -EBADF;
-       file = fget(fd);
+       file = fget_raw_light(fd, &fput_needed);
        if (!file)
                goto out;
 
@@ -414,7 +414,7 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
        if (!error)
                set_fs_pwd(current->fs, &file->f_path);
 out_putf:
-       fput(file);
+       fput_light(file, fput_needed);
 out:
        return error;
 }
@@ -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;
                }
        }