lkml.org 
[lkml]   [2012]   [Sep]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] procfs: don't need a PATH_MAX allocation to hold a string representation of an int
On Fri,  7 Sep 2012 08:34:53 -0400
Jeff Layton <jlayton@redhat.com> wrote:

> Signed-off-by: Jeff Layton <jlayton@redhat.com>
> ---
> fs/proc/base.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/fs/proc/base.c b/fs/proc/base.c
> index 1b6c84c..58e801b 100644
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -2758,7 +2758,8 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
> pid_t tgid = task_tgid_nr_ns(current, ns);
> char *name = ERR_PTR(-ENOENT);
> if (tgid) {
> - name = __getname();
> + /* 10 for max length of an int in decimal + NULL terminator */
> + name = kmalloc(11, GFP_KERNEL);

^^^^^
Bah...my mistake. This should be "12", since it's possible (though
unlikely) that this value could be negative. Is there a better way to
express "strlen of max representation of an int in decimal" ?

> if (!name)
> name = ERR_PTR(-ENOMEM);
> else
> @@ -2773,7 +2774,7 @@ static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
> {
> char *s = nd_get_link(nd);
> if (!IS_ERR(s))
> - __putname(s);
> + kfree(s);
> }
>
> static const struct inode_operations proc_self_inode_operations = {


--
Jeff Layton <jlayton@poochiereds.net>


\
 
 \ /
  Last update: 2012-09-07 15:42    [W:0.697 / U:0.676 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site