[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5049EF5B.3020607@draigBrady.com>
Date: Fri, 07 Sep 2012 13:58:03 +0100
From: Pádraig Brady <P@...igBrady.com>
To: Jeff Layton <jlayton@...chiereds.net>
CC: viro@...iv.linux.org.uk, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] procfs: don't need a PATH_MAX allocation to hold a string
representation of an int
On 09/07/2012 01:48 PM, Jeff Layton wrote:
> On Fri, 7 Sep 2012 08:34:53 -0400
> Jeff Layton<jlayton@...hat.com> wrote:
>
>> Signed-off-by: Jeff Layton<jlayton@...hat.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" ?
See INT_BUFSIZE_BOUND() in:
http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/intprops.h;hb=HEAD
cheers,
Pádraig.
--
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