vfs: fix nd->root leak in do_filp_open()
authorJ. R. Okajima <hooanon05@yahoo.co.jp>
Thu, 18 Jun 2009 14:30:15 +0000 (23:30 +0900)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 24 Jun 2009 12:15:24 +0000 (08:15 -0400)
commit 2a737871108de9ba8930f7650d549f1383767f8b "Cache root in nameidata"
introduced a new member nd->root, but forgot to put it in do_filp_open().

Signed-off-by: J. R. Okajima <hooanon05@yahoo.co.jp>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/namei.c

index 527119afb6a5cca3bea37efde7e6206e04052795..5b961eb71cbf9781988b50559ff10842f49e483a 100644 (file)
@@ -1698,8 +1698,11 @@ struct file *do_filp_open(int dfd, const char *pathname,
        if (error)
                return ERR_PTR(error);
        error = path_walk(pathname, &nd);
-       if (error)
+       if (error) {
+               if (nd.root.mnt)
+                       path_put(&nd.root);
                return ERR_PTR(error);
+       }
        if (unlikely(!audit_dummy_context()))
                audit_inode(pathname, nd.path.dentry);
 
@@ -1759,6 +1762,8 @@ do_last:
                }
                filp = nameidata_to_filp(&nd, open_flag);
                mnt_drop_write(nd.path.mnt);
+               if (nd.root.mnt)
+                       path_put(&nd.root);
                return filp;
        }
 
@@ -1819,6 +1824,8 @@ ok:
         */
        if (will_write)
                mnt_drop_write(nd.path.mnt);
+       if (nd.root.mnt)
+               path_put(&nd.root);
        return filp;
 
 exit_mutex_unlock:
@@ -1859,6 +1866,8 @@ do_link:
                 * with "intent.open".
                 */
                release_open_intent(&nd);
+               if (nd.root.mnt)
+                       path_put(&nd.root);
                return ERR_PTR(error);
        }
        nd.flags &= ~LOOKUP_PARENT;