]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/open.c
[ARM] 4904/1: [AT91] Pass ECC controller to NAND driver
[linux-2.6-omap-h63xx.git] / fs / open.c
index 279aacf256001b356e42da929dc8149c054d5029..a4b12022edaa27cb8cd3ea865d14f1368d507660 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -130,7 +130,7 @@ asmlinkage long sys_statfs(const char __user * path, struct statfs __user * buf)
                error = vfs_statfs_native(nd.path.dentry, &tmp);
                if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
                        error = -EFAULT;
-               path_release(&nd);
+               path_put(&nd.path);
        }
        return error;
 }
@@ -149,7 +149,7 @@ asmlinkage long sys_statfs64(const char __user *path, size_t sz, struct statfs64
                error = vfs_statfs64(nd.path.dentry, &tmp);
                if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
                        error = -EFAULT;
-               path_release(&nd);
+               path_put(&nd.path);
        }
        return error;
 }
@@ -277,7 +277,7 @@ static long do_sys_truncate(const char __user * path, loff_t length)
 put_write_and_out:
        put_write_access(inode);
 dput_and_out:
-       path_release(&nd);
+       path_put(&nd.path);
 out:
        return error;
 }
@@ -462,7 +462,7 @@ asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode)
                res = -EROFS;
 
 out_path_release:
-       path_release(&nd);
+       path_put(&nd.path);
 out:
        current->fsuid = old_fsuid;
        current->fsgid = old_fsgid;
@@ -490,10 +490,10 @@ asmlinkage long sys_chdir(const char __user * filename)
        if (error)
                goto dput_and_out;
 
-       set_fs_pwd(current->fs, nd.path.mnt, nd.path.dentry);
+       set_fs_pwd(current->fs, &nd.path);
 
 dput_and_out:
-       path_release(&nd);
+       path_put(&nd.path);
 out:
        return error;
 }
@@ -501,9 +501,7 @@ out:
 asmlinkage long sys_fchdir(unsigned int fd)
 {
        struct file *file;
-       struct dentry *dentry;
        struct inode *inode;
-       struct vfsmount *mnt;
        int error;
 
        error = -EBADF;
@@ -511,9 +509,7 @@ asmlinkage long sys_fchdir(unsigned int fd)
        if (!file)
                goto out;
 
-       dentry = file->f_path.dentry;
-       mnt = file->f_path.mnt;
-       inode = dentry->d_inode;
+       inode = file->f_path.dentry->d_inode;
 
        error = -ENOTDIR;
        if (!S_ISDIR(inode->i_mode))
@@ -521,7 +517,7 @@ asmlinkage long sys_fchdir(unsigned int fd)
 
        error = file_permission(file, MAY_EXEC);
        if (!error)
-               set_fs_pwd(current->fs, mnt, dentry);
+               set_fs_pwd(current->fs, &file->f_path);
 out_putf:
        fput(file);
 out:
@@ -545,11 +541,11 @@ asmlinkage long sys_chroot(const char __user * filename)
        if (!capable(CAP_SYS_CHROOT))
                goto dput_and_out;
 
-       set_fs_root(current->fs, nd.path.mnt, nd.path.dentry);
+       set_fs_root(current->fs, &nd.path);
        set_fs_altroot();
        error = 0;
 dput_and_out:
-       path_release(&nd);
+       path_put(&nd.path);
 out:
        return error;
 }
@@ -621,7 +617,7 @@ asmlinkage long sys_fchmodat(int dfd, const char __user *filename,
        mutex_unlock(&inode->i_mutex);
 
 dput_and_out:
-       path_release(&nd);
+       path_put(&nd.path);
 out:
        return error;
 }
@@ -676,7 +672,7 @@ asmlinkage long sys_chown(const char __user * filename, uid_t user, gid_t group)
        if (error)
                goto out;
        error = chown_common(nd.path.dentry, user, group);
-       path_release(&nd);
+       path_put(&nd.path);
 out:
        return error;
 }
@@ -696,7 +692,7 @@ asmlinkage long sys_fchownat(int dfd, const char __user *filename, uid_t user,
        if (error)
                goto out;
        error = chown_common(nd.path.dentry, user, group);
-       path_release(&nd);
+       path_put(&nd.path);
 out:
        return error;
 }
@@ -710,7 +706,7 @@ asmlinkage long sys_lchown(const char __user * filename, uid_t user, gid_t group
        if (error)
                goto out;
        error = chown_common(nd.path.dentry, user, group);
-       path_release(&nd);
+       path_put(&nd.path);
 out:
        return error;
 }
@@ -894,7 +890,7 @@ struct file *nameidata_to_filp(struct nameidata *nd, int flags)
                filp = __dentry_open(nd->path.dentry, nd->path.mnt, flags, filp,
                                     NULL);
        else
-               path_release(nd);
+               path_put(&nd->path);
        return filp;
 }
 
@@ -907,6 +903,18 @@ struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
        int error;
        struct file *f;
 
+       /*
+        * We must always pass in a valid mount pointer.   Historically
+        * callers got away with not passing it, but we must enforce this at
+        * the earliest possible point now to avoid strange problems deep in the
+        * filesystem stack.
+        */
+       if (!mnt) {
+               printk(KERN_WARNING "%s called with NULL vfsmount\n", __func__);
+               dump_stack();
+               return ERR_PTR(-EINVAL);
+       }
+
        error = -ENFILE;
        f = get_empty_filp();
        if (f == NULL) {