]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
cpuset: fix error handling regression in proc_cpuset_show()
authorTejun Heo <tj@kernel.org>
Thu, 29 Sep 2016 09:58:36 +0000 (11:58 +0200)
committerTejun Heo <tj@kernel.org>
Thu, 29 Sep 2016 13:55:02 +0000 (15:55 +0200)
4c737b41de7f ("cgroup: make cgroup_path() and friends behave in the
style of strlcpy()") botched the conversion of proc_cpuset_show() and
broke its error handling.  It made the function return 0 on failures
and fail to handle error returns from cgroup_path_ns().  Fix it.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/cpuset.c

index 793ae6fd96dcd2118f410a4c6813d257b05d84da..97dd8e17878644026dca9d809ac3791333681eeb 100644 (file)
@@ -2698,12 +2698,13 @@ int proc_cpuset_show(struct seq_file *m, struct pid_namespace *ns,
        if (!buf)
                goto out;
 
-       retval = -ENAMETOOLONG;
        css = task_get_css(tsk, cpuset_cgrp_id);
        retval = cgroup_path_ns(css->cgroup, buf, PATH_MAX,
                                current->nsproxy->cgroup_ns);
        css_put(css);
        if (retval >= PATH_MAX)
+               retval = -ENAMETOOLONG;
+       if (retval < 0)
                goto out_free;
        seq_puts(m, buf);
        seq_putc(m, '\n');
@@ -2711,7 +2712,7 @@ int proc_cpuset_show(struct seq_file *m, struct pid_namespace *ns,
 out_free:
        kfree(buf);
 out:
-       return 0;
+       return retval;
 }
 #endif /* CONFIG_PROC_PID_CPUSET */