From: Kamalesh Babulal Date: Mon, 14 Feb 2022 15:11:39 +0000 (-0700) Subject: api.c: fix a comparison error in cgroup_delete_cgroup_ext() X-Git-Tag: v3.0~200 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=203eb13b217311635d3afb082f0234c2618b5504;p=thirdparty%2Flibcgroup.git api.c: fix a comparison error in cgroup_delete_cgroup_ext() Fix a comparison logic in the first_errno assignment, that would never get executed in the case of first_errno == ECGNONEMPTY in cgroup_delete_cgroup_ext(). Reported-by: LGTM Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka --- diff --git a/src/api.c b/src/api.c index 4e3fe470..ab24fdb3 100644 --- a/src/api.c +++ b/src/api.c @@ -3072,13 +3072,14 @@ int cgroup_delete_cgroup_ext(struct cgroup *cgroup, int flags) * error code, but continue with next controller and try remove * the group from all of them. */ - if (ret != 0 && first_error == 0) { + if (ret) { /* * ECGNONEMPTY is more or less not an error, but an * indication that something was not removed. * Therefore it should be replaced by any other error. */ - if (ret != ECGNONEMPTY || first_error == ECGNONEMPTY) { + if (ret != ECGNONEMPTY && + (first_error == 0 || first_errno == ECGNONEMPTY)) { first_errno = last_errno; first_error = ret; }