]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
wrapper.c: return on failure in cgroup_add_all_controllers()
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Fri, 8 Jul 2022 16:37:09 +0000 (10:37 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Fri, 8 Jul 2022 16:38:22 +0000 (10:38 -0600)
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 <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
TJH: Also fix unrelated grammar error near this change.

src/wrapper.c

index c3d766d223a9cb4eee94df65f76fa5c37a6fbc1b..8f23372f783bf776aed875981c17d0eb50c7cdd1 100644 (file)
@@ -135,8 +135,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: