Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[linux-2.6-microblaze.git] / fs / namei.c
index 6f0dc40..a59968d 100644 (file)
@@ -3365,7 +3365,9 @@ finish_open_created:
                goto out;
        *opened |= FILE_OPENED;
 opened:
-       error = ima_file_check(file, op->acc_mode, *opened);
+       error = open_check_o_direct(file);
+       if (!error)
+               error = ima_file_check(file, op->acc_mode, *opened);
        if (!error && will_truncate)
                error = handle_truncate(file);
 out:
@@ -3445,6 +3447,9 @@ static int do_tmpfile(struct nameidata *nd, unsigned flags,
        error = finish_open(file, child, NULL, opened);
        if (error)
                goto out2;
+       error = open_check_o_direct(file);
+       if (error)
+               fput(file);
 out2:
        mnt_drop_write(path.mnt);
 out:
@@ -3845,11 +3850,11 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry)
        if (error)
                goto out;
 
-       shrink_dcache_parent(dentry);
        error = dir->i_op->rmdir(dir, dentry);
        if (error)
                goto out;
 
+       shrink_dcache_parent(dentry);
        dentry->d_inode->i_flags |= S_DEAD;
        dont_mount(dentry);
        detach_mounts(dentry);
@@ -4432,8 +4437,6 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                    old_dir->i_nlink >= max_links)
                        goto out;
        }
-       if (is_dir && !(flags & RENAME_EXCHANGE) && target)
-               shrink_dcache_parent(new_dentry);
        if (!is_dir) {
                error = try_break_deleg(source, delegated_inode);
                if (error)
@@ -4450,8 +4453,10 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                goto out;
 
        if (!(flags & RENAME_EXCHANGE) && target) {
-               if (is_dir)
+               if (is_dir) {
+                       shrink_dcache_parent(new_dentry);
                        target->i_flags |= S_DEAD;
+               }
                dont_mount(new_dentry);
                detach_mounts(new_dentry);
        }