Skip to content

Commit

Permalink
teach proc_self_get_link()/proc_thread_self_get_link() to work in RCU…
Browse files Browse the repository at this point in the history
… mode

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Dec 9, 2015
1 parent 6a6c990 commit 1a384ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
8 changes: 3 additions & 5 deletions fs/proc/self.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ static const char *proc_self_get_link(struct dentry *dentry,
pid_t tgid = task_tgid_nr_ns(current, ns);
char *name;

if (!dentry)
return ERR_PTR(-ECHILD);
if (!tgid)
return ERR_PTR(-ENOENT);
/* 11 for max length of signed int in decimal + NULL term */
name = kmalloc(12, GFP_KERNEL);
if (!name)
return ERR_PTR(-ENOMEM);
name = kmalloc(12, dentry ? GFP_KERNEL : GFP_ATOMIC);
if (unlikely(!name))
return dentry ? ERR_PTR(-ENOMEM) : ERR_PTR(-ECHILD);
sprintf(name, "%d", tgid);
return *cookie = name;
}
Expand Down
9 changes: 4 additions & 5 deletions fs/proc/thread_self.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ static const char *proc_thread_self_get_link(struct dentry *dentry,
pid_t pid = task_pid_nr_ns(current, ns);
char *name;

if (!dentry)
return ERR_PTR(-ECHILD);
if (!pid)
return ERR_PTR(-ENOENT);
name = kmalloc(PROC_NUMBUF + 6 + PROC_NUMBUF, GFP_KERNEL);
if (!name)
return ERR_PTR(-ENOMEM);
name = kmalloc(PROC_NUMBUF + 6 + PROC_NUMBUF,
dentry ? GFP_KERNEL : GFP_ATOMIC);
if (unlikely(!name))
return dentry ? ERR_PTR(-ENOMEM) : ERR_PTR(-ECHILD);
sprintf(name, "%d/task/%d", tgid, pid);
return *cookie = name;
}
Expand Down

0 comments on commit 1a384ea

Please sign in to comment.