vfs - fix dentry ref count in do_lookup()
authorIan Kent <raven@themaw.net>
Tue, 18 Jan 2011 04:06:10 +0000 (12:06 +0800)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 18 Jan 2011 06:21:26 +0000 (01:21 -0500)
There is a ref count problem in fs/namei.c:do_lookup().

When walking in ref-walk mode, if follow_managed() returns a fail we
need to drop dentry and possibly vfsmount.  Clean up properly,
as we do in the other caller of follow_managed().

Signed-off-by: Ian Kent <raven@themaw.net>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/namei.c

index b753192..7d77f24 100644 (file)
@@ -1272,8 +1272,10 @@ done:
        path->mnt = mnt;
        path->dentry = dentry;
        err = follow_managed(path, nd->flags);
-       if (unlikely(err < 0))
+       if (unlikely(err < 0)) {
+               path_put_conditional(path, nd);
                return err;
+       }
        *inode = path->dentry->d_inode;
        return 0;