diff options
author | Tejun Heo <tj@kernel.org> | 2016-09-29 05:58:36 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2016-09-29 09:55:02 -0400 |
commit | 679a5e3f12830392d14f94b04bbe0f3cabdbd773 (patch) | |
tree | 075922558e658517eb69a5276f458ee7e97add06 | |
parent | ed1777de25e45bfb58fad63341904f8a77911785 (diff) |
cpuset: fix error handling regression in proc_cpuset_show()
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>
-rw-r--r-- | kernel/cpuset.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 793ae6fd96dc..97dd8e178786 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
@@ -2698,12 +2698,13 @@ int proc_cpuset_show(struct seq_file *m, struct pid_namespace *ns, | |||
2698 | if (!buf) | 2698 | if (!buf) |
2699 | goto out; | 2699 | goto out; |
2700 | 2700 | ||
2701 | retval = -ENAMETOOLONG; | ||
2702 | css = task_get_css(tsk, cpuset_cgrp_id); | 2701 | css = task_get_css(tsk, cpuset_cgrp_id); |
2703 | retval = cgroup_path_ns(css->cgroup, buf, PATH_MAX, | 2702 | retval = cgroup_path_ns(css->cgroup, buf, PATH_MAX, |
2704 | current->nsproxy->cgroup_ns); | 2703 | current->nsproxy->cgroup_ns); |
2705 | css_put(css); | 2704 | css_put(css); |
2706 | if (retval >= PATH_MAX) | 2705 | if (retval >= PATH_MAX) |
2706 | retval = -ENAMETOOLONG; | ||
2707 | if (retval < 0) | ||
2707 | goto out_free; | 2708 | goto out_free; |
2708 | seq_puts(m, buf); | 2709 | seq_puts(m, buf); |
2709 | seq_putc(m, '\n'); | 2710 | seq_putc(m, '\n'); |
@@ -2711,7 +2712,7 @@ int proc_cpuset_show(struct seq_file *m, struct pid_namespace *ns, | |||
2711 | out_free: | 2712 | out_free: |
2712 | kfree(buf); | 2713 | kfree(buf); |
2713 | out: | 2714 | out: |
2714 | return 0; | 2715 | return retval; |
2715 | } | 2716 | } |
2716 | #endif /* CONFIG_PROC_PID_CPUSET */ | 2717 | #endif /* CONFIG_PROC_PID_CPUSET */ |
2717 | 2718 | ||