From: "Aneesh Kumar K. V" <aneesh.kumar@linux.vnet.ibm.com>
To: "M. Mohan Kumar" <mohan@in.ibm.com>,
v9fs-developer <v9fs-developer@lists.sourceforge.net>,
"linux-fsdevel\@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] [V2] fs/9p: TREADLINK bugfix
Date: Thu, 06 Jan 2011 10:50:26 +0530 [thread overview]
Message-ID: <87zkre38x1.fsf@linux.vnet.ibm.com> (raw)
In-Reply-To: <1294246196-8354-1-git-send-email-mohan@in.ibm.com>
On Wed, 5 Jan 2011 22:19:56 +0530, "M. Mohan Kumar" <mohan@in.ibm.com> wrote:
> Remove v9fs_vfs_readlink_dotl function and use generic_readlink. Update
> v9fs_vfs_follow_link_dotl function to accommodate this change
>
> Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
> Reported-by: Dr. David Alan Gilbert <linux@treblig.org>
> ---
> Changes from previous version:
> * Use __getname in v9fs_vfs_follow_link_dotl
> * Remove v9fs_vfs_readlink_dotl function
>
> fs/9p/vfs_inode.c | 53 +++++++++++++++++------------------------------------
> 1 files changed, 17 insertions(+), 36 deletions(-)
>
> diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
> index 2ce3668..7e613e8 100644
> --- a/fs/9p/vfs_inode.c
> +++ b/fs/9p/vfs_inode.c
> @@ -1994,30 +1994,6 @@ error:
> return err;
> }
>
> -static int
> -v9fs_vfs_readlink_dotl(struct dentry *dentry, char *buffer, int buflen)
> -{
> - int retval;
> - struct p9_fid *fid;
> - char *target = NULL;
> -
> - P9_DPRINTK(P9_DEBUG_VFS, " %s\n", dentry->d_name.name);
> - retval = -EPERM;
> - fid = v9fs_fid_lookup(dentry);
> - if (IS_ERR(fid))
> - return PTR_ERR(fid);
> -
> - retval = p9_client_readlink(fid, &target);
> - if (retval < 0)
> - return retval;
> -
> - strncpy(buffer, target, buflen);
> - P9_DPRINTK(P9_DEBUG_VFS, "%s -> %s\n", dentry->d_name.name, buffer);
> -
> - retval = strnlen(buffer, buflen);
> - return retval;
> -}
> -
> /**
> * v9fs_vfs_follow_link_dotl - follow a symlink path
> * @dentry: dentry for symlink
> @@ -2028,23 +2004,28 @@ v9fs_vfs_readlink_dotl(struct dentry *dentry, char *buffer, int buflen)
> static void *
> v9fs_vfs_follow_link_dotl(struct dentry *dentry, struct nameidata *nd)
> {
> - int len = 0;
> + int retval;
> + struct p9_fid *fid;
> char *link = __getname();
> + char *target;
>
> - P9_DPRINTK(P9_DEBUG_VFS, "%s n", dentry->d_name.name);
> + P9_DPRINTK(P9_DEBUG_VFS, "%s\n", dentry->d_name.name);
>
> if (!link)
> - link = ERR_PTR(-ENOMEM);
> - else {
> - len = v9fs_vfs_readlink_dotl(dentry, link, PATH_MAX);
> - if (len < 0) {
> - __putname(link);
> - link = ERR_PTR(len);
> - } else
> - link[min(len, PATH_MAX-1)] = 0;
> + return NULL;
> + fid = v9fs_fid_lookup(dentry);
> + if (IS_ERR(fid))
> + return fid;
need to do a __putname(link) and do a nd_set_link(nd, ERR_PTR(fid))
> + retval = p9_client_readlink(fid, &target);
> + if (retval < 0) {
> + __putname(link);
> + kfree(target);
On error target should not be allocated right ? So why kfree ?
> + return NULL;
> }
> - nd_set_link(nd, link);
>
> + strcpy(link, target);
> + nd_set_link(nd, link);
> + kfree(target);
> return NULL;
> }
>
-aneesh
WARNING: multiple messages have this Message-ID (diff)
From: "Aneesh Kumar K. V" <aneesh.kumar@linux.vnet.ibm.com>
To: "M. Mohan Kumar" <mohan@in.ibm.com>,
v9fs-developer <v9fs-developer@lists.sourceforge.net>,
"linux-fsdevel\@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
LKML <linux-kernel@vger.k
Subject: Re: [PATCH] [V2] fs/9p: TREADLINK bugfix
Date: Thu, 06 Jan 2011 10:50:26 +0530 [thread overview]
Message-ID: <87zkre38x1.fsf@linux.vnet.ibm.com> (raw)
In-Reply-To: <1294246196-8354-1-git-send-email-mohan@in.ibm.com>
On Wed, 5 Jan 2011 22:19:56 +0530, "M. Mohan Kumar" <mohan@in.ibm.com> wrote:
> Remove v9fs_vfs_readlink_dotl function and use generic_readlink. Update
> v9fs_vfs_follow_link_dotl function to accommodate this change
>
> Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
> Reported-by: Dr. David Alan Gilbert <linux@treblig.org>
> ---
> Changes from previous version:
> * Use __getname in v9fs_vfs_follow_link_dotl
> * Remove v9fs_vfs_readlink_dotl function
>
> fs/9p/vfs_inode.c | 53 +++++++++++++++++------------------------------------
> 1 files changed, 17 insertions(+), 36 deletions(-)
>
> diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
> index 2ce3668..7e613e8 100644
> --- a/fs/9p/vfs_inode.c
> +++ b/fs/9p/vfs_inode.c
> @@ -1994,30 +1994,6 @@ error:
> return err;
> }
>
> -static int
> -v9fs_vfs_readlink_dotl(struct dentry *dentry, char *buffer, int buflen)
> -{
> - int retval;
> - struct p9_fid *fid;
> - char *target = NULL;
> -
> - P9_DPRINTK(P9_DEBUG_VFS, " %s\n", dentry->d_name.name);
> - retval = -EPERM;
> - fid = v9fs_fid_lookup(dentry);
> - if (IS_ERR(fid))
> - return PTR_ERR(fid);
> -
> - retval = p9_client_readlink(fid, &target);
> - if (retval < 0)
> - return retval;
> -
> - strncpy(buffer, target, buflen);
> - P9_DPRINTK(P9_DEBUG_VFS, "%s -> %s\n", dentry->d_name.name, buffer);
> -
> - retval = strnlen(buffer, buflen);
> - return retval;
> -}
> -
> /**
> * v9fs_vfs_follow_link_dotl - follow a symlink path
> * @dentry: dentry for symlink
> @@ -2028,23 +2004,28 @@ v9fs_vfs_readlink_dotl(struct dentry *dentry, char *buffer, int buflen)
> static void *
> v9fs_vfs_follow_link_dotl(struct dentry *dentry, struct nameidata *nd)
> {
> - int len = 0;
> + int retval;
> + struct p9_fid *fid;
> char *link = __getname();
> + char *target;
>
> - P9_DPRINTK(P9_DEBUG_VFS, "%s n", dentry->d_name.name);
> + P9_DPRINTK(P9_DEBUG_VFS, "%s\n", dentry->d_name.name);
>
> if (!link)
> - link = ERR_PTR(-ENOMEM);
> - else {
> - len = v9fs_vfs_readlink_dotl(dentry, link, PATH_MAX);
> - if (len < 0) {
> - __putname(link);
> - link = ERR_PTR(len);
> - } else
> - link[min(len, PATH_MAX-1)] = 0;
> + return NULL;
> + fid = v9fs_fid_lookup(dentry);
> + if (IS_ERR(fid))
> + return fid;
need to do a __putname(link) and do a nd_set_link(nd, ERR_PTR(fid))
> + retval = p9_client_readlink(fid, &target);
> + if (retval < 0) {
> + __putname(link);
> + kfree(target);
On error target should not be allocated right ? So why kfree ?
> + return NULL;
> }
> - nd_set_link(nd, link);
>
> + strcpy(link, target);
> + nd_set_link(nd, link);
> + kfree(target);
> return NULL;
> }
>
-aneesh
next prev parent reply other threads:[~2011-01-06 5:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-05 16:49 [PATCH] [V2] fs/9p: TREADLINK bugfix M. Mohan Kumar
2011-01-05 17:28 ` Aneesh Kumar K. V
2011-01-05 17:28 ` Aneesh Kumar K. V
2011-01-06 5:20 ` Aneesh Kumar K. V [this message]
2011-01-06 5:20 ` Aneesh Kumar K. V
2011-01-06 5:55 ` M. Mohan Kumar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zkre38x1.fsf@linux.vnet.ibm.com \
--to=aneesh.kumar@linux.vnet.ibm.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mohan@in.ibm.com \
--cc=v9fs-developer@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.