don't modify od->filp at all
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 10 Jun 2012 09:04:43 +0000 (05:04 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sat, 14 Jul 2012 12:33:33 +0000 (16:33 +0400)
make put_filp() conditional on flag set by finish_open()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/namei.c
fs/open.c

index 7a33f074e5bd3cc645deb2d33ba09e09c23f4054..18b9326d951f060e206feb12049325b165683e3b 100644 (file)
@@ -2708,10 +2708,8 @@ out:
                path_put(&nd->root);
        if (base)
                fput(base);
-       if (od.filp) {
-               BUG_ON(od.filp->f_path.dentry);
+       if (!(opened & FILE_OPENED))
                put_filp(od.filp);
-       }
        if (res == ERR_PTR(-EOPENSTALE)) {
                if (flags & LOOKUP_RCU)
                        res = ERR_PTR(-ECHILD);
index 89589bd3993cacce7e2de75ead8f79cce4240730..c87f98201c2990d572270978c9a6812a98d7a82f 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -786,15 +786,14 @@ struct file *finish_open(struct opendata *od, struct dentry *dentry,
                         int *opened)
 {
        struct file *res;
+       BUG_ON(*opened & FILE_OPENED); /* once it's opened, it's opened */
 
        mntget(od->mnt);
        dget(dentry);
 
        res = do_dentry_open(dentry, od->mnt, od->filp, open, current_cred());
-       if (!IS_ERR(res)) {
+       if (!IS_ERR(res))
                *opened |= FILE_OPENED;
-               od->filp = NULL;
-       }
 
        return res;
 }