diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2018-02-07 00:36:51 +0100 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-02-07 03:32:43 +0100 |
commit | e3912ac37e07a13c70675cd75020694de4841c74 (patch) | |
tree | 78d2e8a58b5ff64444fedfa542fbaccd3d9a86c1 /fs/proc/self.c | |
parent | kasan: remove redundant initialization of variable 'real_size' (diff) | |
download | linux-e3912ac37e07a13c70675cd75020694de4841c74.tar.xz linux-e3912ac37e07a13c70675cd75020694de4841c74.zip |
proc: use %u for pid printing and slightly less stack
PROC_NUMBUF is 13 which is enough for "negative int + \n + \0".
However PIDs and TGIDs are never negative and newline is not a concern,
so use just 10 per integer.
Link: http://lkml.kernel.org/r/20171120203005.GA27743@avx2
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Alexander Viro <viro@ftp.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/proc/self.c')
-rw-r--r-- | fs/proc/self.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/proc/self.c b/fs/proc/self.c index 31326bb23b8b..d30627aa440b 100644 --- a/fs/proc/self.c +++ b/fs/proc/self.c @@ -17,11 +17,11 @@ static const char *proc_self_get_link(struct dentry *dentry, if (!tgid) return ERR_PTR(-ENOENT); - /* 11 for max length of signed int in decimal + NULL term */ - name = kmalloc(12, dentry ? GFP_KERNEL : GFP_ATOMIC); + /* max length of unsigned int in decimal + NULL term */ + name = kmalloc(10 + 1, dentry ? GFP_KERNEL : GFP_ATOMIC); if (unlikely(!name)) return dentry ? ERR_PTR(-ENOMEM) : ERR_PTR(-ECHILD); - sprintf(name, "%d", tgid); + sprintf(name, "%u", tgid); set_delayed_call(done, kfree_link, name); return name; } |