teach proc_self_get_link()/proc_thread_self_get_link() to work in RCU mode

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2015-11-17 10:58:42 -05:00
Родитель 6a6c990496
Коммит 1a384eaac2
2 изменённых файлов: 7 добавлений и 10 удалений

Просмотреть файл

@ -25,14 +25,12 @@ static const char *proc_self_get_link(struct dentry *dentry,
pid_t tgid = task_tgid_nr_ns(current, ns); pid_t tgid = task_tgid_nr_ns(current, ns);
char *name; char *name;
if (!dentry)
return ERR_PTR(-ECHILD);
if (!tgid) if (!tgid)
return ERR_PTR(-ENOENT); return ERR_PTR(-ENOENT);
/* 11 for max length of signed int in decimal + NULL term */ /* 11 for max length of signed int in decimal + NULL term */
name = kmalloc(12, GFP_KERNEL); name = kmalloc(12, dentry ? GFP_KERNEL : GFP_ATOMIC);
if (!name) if (unlikely(!name))
return ERR_PTR(-ENOMEM); return dentry ? ERR_PTR(-ENOMEM) : ERR_PTR(-ECHILD);
sprintf(name, "%d", tgid); sprintf(name, "%d", tgid);
return *cookie = name; return *cookie = name;
} }

Просмотреть файл

@ -27,13 +27,12 @@ static const char *proc_thread_self_get_link(struct dentry *dentry,
pid_t pid = task_pid_nr_ns(current, ns); pid_t pid = task_pid_nr_ns(current, ns);
char *name; char *name;
if (!dentry)
return ERR_PTR(-ECHILD);
if (!pid) if (!pid)
return ERR_PTR(-ENOENT); return ERR_PTR(-ENOENT);
name = kmalloc(PROC_NUMBUF + 6 + PROC_NUMBUF, GFP_KERNEL); name = kmalloc(PROC_NUMBUF + 6 + PROC_NUMBUF,
if (!name) dentry ? GFP_KERNEL : GFP_ATOMIC);
return ERR_PTR(-ENOMEM); if (unlikely(!name))
return dentry ? ERR_PTR(-ENOMEM) : ERR_PTR(-ECHILD);
sprintf(name, "%d/task/%d", tgid, pid); sprintf(name, "%d/task/%d", tgid, pid);
return *cookie = name; return *cookie = name;
} }