diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2014-03-14 18:42:45 +0100 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-04-02 05:19:15 +0200 |
commit | 5d826c847b34de6415b4f1becd88a57ff619af50 (patch) | |
tree | 431338c4141bcff1d392f232613841bf1971d99b /fs/proc/namespaces.c | |
parent | lustre: generic_readlink() is just fine there, TYVM... (diff) | |
download | linux-5d826c847b34de6415b4f1becd88a57ff619af50.tar.xz linux-5d826c847b34de6415b4f1becd88a57ff619af50.zip |
new helper: readlink_copy()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/proc/namespaces.c')
-rw-r--r-- | fs/proc/namespaces.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c index 9ae46b87470d..89026095f2b5 100644 --- a/fs/proc/namespaces.c +++ b/fs/proc/namespaces.c @@ -146,7 +146,7 @@ static int proc_ns_readlink(struct dentry *dentry, char __user *buffer, int bufl struct task_struct *task; void *ns; char name[50]; - int len = -EACCES; + int res = -EACCES; task = get_proc_task(inode); if (!task) @@ -155,24 +155,18 @@ static int proc_ns_readlink(struct dentry *dentry, char __user *buffer, int bufl if (!ptrace_may_access(task, PTRACE_MODE_READ)) goto out_put_task; - len = -ENOENT; + res = -ENOENT; ns = ns_ops->get(task); if (!ns) goto out_put_task; snprintf(name, sizeof(name), "%s:[%u]", ns_ops->name, ns_ops->inum(ns)); - len = strlen(name); - - if (len > buflen) - len = buflen; - if (copy_to_user(buffer, name, len)) - len = -EFAULT; - + res = readlink_copy(buffer, buflen, name); ns_ops->put(ns); out_put_task: put_task_struct(task); out: - return len; + return res; } static const struct inode_operations proc_ns_link_inode_operations = { |