summaryrefslogtreecommitdiffstats
path: root/fs/proc/self.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/proc/self.c')
-rw-r--r--fs/proc/self.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/fs/proc/self.c b/fs/proc/self.c
index 113b8d061fc0..67e8db442cf0 100644
--- a/fs/proc/self.c
+++ b/fs/proc/self.c
@@ -18,26 +18,28 @@ static int proc_self_readlink(struct dentry *dentry, char __user *buffer,
18 return readlink_copy(buffer, buflen, tmp); 18 return readlink_copy(buffer, buflen, tmp);
19} 19}
20 20
21static const char *proc_self_follow_link(struct dentry *dentry, void **cookie) 21static const char *proc_self_get_link(struct dentry *dentry,
22 struct inode *inode,
23 struct delayed_call *done)
22{ 24{
23 struct pid_namespace *ns = dentry->d_sb->s_fs_info; 25 struct pid_namespace *ns = inode->i_sb->s_fs_info;
24 pid_t tgid = task_tgid_nr_ns(current, ns); 26 pid_t tgid = task_tgid_nr_ns(current, ns);
25 char *name; 27 char *name;
26 28
27 if (!tgid) 29 if (!tgid)
28 return ERR_PTR(-ENOENT); 30 return ERR_PTR(-ENOENT);
29 /* 11 for max length of signed int in decimal + NULL term */ 31 /* 11 for max length of signed int in decimal + NULL term */
30 name = kmalloc(12, GFP_KERNEL); 32 name = kmalloc(12, dentry ? GFP_KERNEL : GFP_ATOMIC);
31 if (!name) 33 if (unlikely(!name))
32 return ERR_PTR(-ENOMEM); 34 return dentry ? ERR_PTR(-ENOMEM) : ERR_PTR(-ECHILD);
33 sprintf(name, "%d", tgid); 35 sprintf(name, "%d", tgid);
34 return *cookie = name; 36 set_delayed_call(done, kfree_link, name);
37 return name;
35} 38}
36 39
37static const struct inode_operations proc_self_inode_operations = { 40static const struct inode_operations proc_self_inode_operations = {
38 .readlink = proc_self_readlink, 41 .readlink = proc_self_readlink,
39 .follow_link = proc_self_follow_link, 42 .get_link = proc_self_get_link,
40 .put_link = kfree_put_link,
41}; 43};
42 44
43static unsigned self_inum; 45static unsigned self_inum;