diff options
Diffstat (limited to 'fs/proc/self.c')
-rw-r--r-- | fs/proc/self.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/fs/proc/self.c b/fs/proc/self.c index 6195b4a7c3b1..ad333946b53a 100644 --- a/fs/proc/self.c +++ b/fs/proc/self.c | |||
@@ -1,5 +1,4 @@ | |||
1 | #include <linux/sched.h> | 1 | #include <linux/sched.h> |
2 | #include <linux/namei.h> | ||
3 | #include <linux/slab.h> | 2 | #include <linux/slab.h> |
4 | #include <linux/pid_namespace.h> | 3 | #include <linux/pid_namespace.h> |
5 | #include "internal.h" | 4 | #include "internal.h" |
@@ -19,21 +18,20 @@ static int proc_self_readlink(struct dentry *dentry, char __user *buffer, | |||
19 | return readlink_copy(buffer, buflen, tmp); | 18 | return readlink_copy(buffer, buflen, tmp); |
20 | } | 19 | } |
21 | 20 | ||
22 | static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd) | 21 | static const char *proc_self_follow_link(struct dentry *dentry, void **cookie, struct nameidata *nd) |
23 | { | 22 | { |
24 | struct pid_namespace *ns = dentry->d_sb->s_fs_info; | 23 | struct pid_namespace *ns = dentry->d_sb->s_fs_info; |
25 | pid_t tgid = task_tgid_nr_ns(current, ns); | 24 | pid_t tgid = task_tgid_nr_ns(current, ns); |
26 | char *name = ERR_PTR(-ENOENT); | 25 | char *name; |
27 | if (tgid) { | 26 | |
28 | /* 11 for max length of signed int in decimal + NULL term */ | 27 | if (!tgid) |
29 | name = kmalloc(12, GFP_KERNEL); | 28 | return ERR_PTR(-ENOENT); |
30 | if (!name) | 29 | /* 11 for max length of signed int in decimal + NULL term */ |
31 | name = ERR_PTR(-ENOMEM); | 30 | name = kmalloc(12, GFP_KERNEL); |
32 | else | 31 | if (!name) |
33 | sprintf(name, "%d", tgid); | 32 | return ERR_PTR(-ENOMEM); |
34 | } | 33 | sprintf(name, "%d", tgid); |
35 | nd_set_link(nd, name); | 34 | return *cookie = name; |
36 | return NULL; | ||
37 | } | 35 | } |
38 | 36 | ||
39 | static const struct inode_operations proc_self_inode_operations = { | 37 | static const struct inode_operations proc_self_inode_operations = { |