linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@redhat.com>
To: viro@zeniv.linux.org.uk
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2] procfs: don't need a PATH_MAX allocation to hold a string representation of an int
Date: Fri,  7 Sep 2012 13:27:16 -0400	[thread overview]
Message-ID: <1347038836-24806-1-git-send-email-jlayton@redhat.com> (raw)
In-Reply-To: <1347021293-19052-1-git-send-email-jlayton@redhat.com>

This patch is a minor respin that just increases the buffer size by 1
to account for a potential minus sign at the head.

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..3e6ce3f 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();
+		/* 11 for max length of signed int in decimal + NULL term */
+		name = kmalloc(12, GFP_KERNEL);
 		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 = {
-- 
1.7.11.4


      parent reply	other threads:[~2012-09-07 17:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-07 12:34 [PATCH] procfs: don't need a PATH_MAX allocation to hold a string representation of an int Jeff Layton
2012-09-07 12:48 ` Jeff Layton
2012-09-07 12:58   ` Pádraig Brady
2012-09-07 19:44     ` J. Bruce Fields
2012-09-10 13:23       ` Jeff Layton
2012-09-10 14:28         ` J. Bruce Fields
2012-09-07 17:27 ` Jeff Layton [this message]

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=1347038836-24806-1-git-send-email-jlayton@redhat.com \
    --to=jlayton@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).