From: Michael Tremer Date: Sat, 14 Dec 2024 14:09:29 +0000 (+0000) Subject: cgroups: Close the FD after we removed the cgroup X-Git-Tag: 0.9.30~719 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eae2baed9455a5707909373811ea2dc91eccb2f6;p=pakfire.git cgroups: Close the FD after we removed the cgroup Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/cgroup.c b/src/libpakfire/cgroup.c index 786f0f898..6bc1a9615 100644 --- a/src/libpakfire/cgroup.c +++ b/src/libpakfire/cgroup.c @@ -520,17 +520,19 @@ int pakfire_cgroup_destroy(struct pakfire_cgroup* cgroup) { if (r) return r; + // Delete the directory + r = unlinkat(cgroup->parent->fd, cgroup->name, AT_REMOVEDIR); + if (r) { + ERROR(cgroup->ctx, "Could not destroy cgroup %s: %m\n", cgroup->path); + return -errno; + } + // Close the file descriptor if (cgroup->fd >= 0) { close(cgroup->fd); cgroup->fd = -EBADF; } - // Delete the directory - r = unlinkat(cgroup->parent->fd, cgroup->name, AT_REMOVEDIR); - if (r) - ERROR(cgroup->ctx, "Could not destroy cgroup: %m\n"); - return r; }