cgroups: fix fd leaks

They didn't really matter because we want to keep them around for as long as the container lives anyway. Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent 47f56e94
...@@ -86,16 +86,34 @@ void cgroup_exit(struct cgroup_ops *ops) ...@@ -86,16 +86,34 @@ void cgroup_exit(struct cgroup_ops *ops)
free((*it)->mountpoint); free((*it)->mountpoint);
free((*it)->container_base_path); free((*it)->container_base_path);
free((*it)->container_full_path);
free((*it)->monitor_full_path); {
if ((*it)->cgfd_con >= 0) free((*it)->container_full_path);
close((*it)->cgfd_con);
if ((*it)->container_full_path != (*it)->container_limit_path)
free((*it)->monitor_full_path);
}
{
if ((*it)->cgfd_limit >= 0 && (*it)->cgfd_con != (*it)->cgfd_limit)
close((*it)->cgfd_limit);
if ((*it)->cgfd_con >= 0)
close((*it)->cgfd_con);
}
if ((*it)->cgfd_mon >= 0) if ((*it)->cgfd_mon >= 0)
close((*it)->cgfd_mon); close((*it)->cgfd_mon);
if ((*it)->dfd_mnt >= 0)
close((*it)->dfd_mnt); {
if ((*it)->dfd_base >= 0) if ((*it)->dfd_base >= 0 && (*it)->dfd_mnt != (*it)->dfd_base)
close((*it)->dfd_base); close((*it)->dfd_base);
if ((*it)->dfd_mnt >= 0)
close((*it)->dfd_mnt);
}
free(*it); free(*it);
} }
free(ops->hierarchies); free(ops->hierarchies);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment