From 71eb00ef127d4e626699ee4a27a0a14c7d5145ff Mon Sep 17 00:00:00 2001 From: Kamalesh Babulal Date: Fri, 8 Jul 2022 10:42:29 -0600 Subject: [PATCH] wrapper.c: return on failure in cgroup_add_all_controllers() Add missing goto statement, to return on failure, reported by Coverity tool: CID 258281 (#1 of 1): Unused value (UNUSED_VALUE)assigned_value: Assigning value ECGINVAL to ret here, but that stored value is overwritten before it can be used. the tool reported about unused ret value, but it turned out that the NULL ret value is for failed attempt to add a controller to the desired cgroup and needs bailing out after losing the handle. Fix it by introducing the goto statement in cgroup_add_all_controllers() Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka TJH: Also fix unrelated grammar error near this change. (cherry picked from commit 83d64a4474366938e1459403eb0c98c3d3b7ee00) --- src/wrapper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wrapper.c b/src/wrapper.c index 5d9431f3..7dac475b 100644 --- a/src/wrapper.c +++ b/src/wrapper.c @@ -120,8 +120,9 @@ int cgroup_add_all_controllers(struct cgroup *cgroup) cgc = cgroup_add_controller(cgroup, info.name); if (!cgc) { ret = ECGINVAL; - fprintf(stderr, "controller %s can't be add\n", + fprintf(stderr, "controller %s can't be added\n", info.name); + goto end; } next: -- 2.47.2