[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20070506211946.GC13333@infradead.org>
Date: Sun, 6 May 2007 22:19:46 +0100
From: Christoph Hellwig <hch@...radead.org>
To: Josef 'Jeff' Sipek <jsipek@...sunysb.edu>
Cc: linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
hch@...radead.org, akpm@...ux-foundation.org,
viro@....linux.org.uk, Trond.Myklebust@...app.com, neilb@...e.de,
mhalcrow@...ibm.com
Subject: Re: [PATCH 3/5] nfsctl: Use vfs_path_lookup
On Sun, May 06, 2007 at 01:41:27PM -0400, Josef 'Jeff' Sipek wrote:
> use vfs_path_lookup instead of open-coding the necessary functionality.
>
> Signed-off-by: Josef 'Jeff' Sipek <jsipek@...sunysb.edu>
> ---
> fs/nfsctl.c | 15 +++++----------
> 1 files changed, 5 insertions(+), 10 deletions(-)
>
> diff --git a/fs/nfsctl.c b/fs/nfsctl.c
> index c043136..c97df14 100644
> --- a/fs/nfsctl.c
> +++ b/fs/nfsctl.c
> @@ -23,19 +23,14 @@
> static struct file *do_open(char *name, int flags)
> {
> struct nameidata nd;
> + struct vfsmount *mnt;
> int error;
>
> - nd.mnt = do_kern_mount("nfsd", 0, "nfsd", NULL);
> + mnt = do_kern_mount("nfsd", 0, "nfsd", NULL);
> + if (IS_ERR(mnt))
> + return (struct file *)mnt;
>
> - if (IS_ERR(nd.mnt))
> - return (struct file *)nd.mnt;
> -
> - nd.dentry = dget(nd.mnt->mnt_root);
> - nd.last_type = LAST_ROOT;
> - nd.flags = 0;
> - nd.depth = 0;
> -
> - error = path_walk(name, &nd);
> + error = vfs_path_lookup(mnt->mnt_root, mnt, name, 0, &nd);
> if (error)
> return ERR_PTR(error);
I think you're leaking a reference on the mount here as we didn't
do a mntget before. We need to do an additional mntput just after
the lookup to drop the reference from do_kern_mount.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists