Hi
Calling cgroup_free_controllers() with null cgroup gives segmentation fault.
A simple call to
cgroup_free_controllers(cgroup2);
gives this segfault. cgroup2 is null.
The following patch fixes this issue.
--- trunk.orig/wrapper.c
+++ trunk/wrapper.c
@@ -76,6 +76,10 @@ struct cgroup_controller *cgroup_add_con
void cgroup_free_controllers(struct cgroup *cgroup)
{
int i, j;
+
+ if (!cgroup)
+ return;
+
for (i = 0; i < cgroup->index; i++) {
for (j = 0; j < cgroup->controller[i]->index; j++)
free(cgroup->controller[i]->values[j]);
~
Though I have merged the patch in, i don;t believe its the right solution. cgroup_free checks if the cgroup is null before passing it on. a null cgroup should never have made it there. This needs deeper checking. Sudhir, can I ask you to provide the gdb trace for this.
But one can not guarantee that an independent call will not be made to cgroup_freee_controllers(). If it is through cgroup_free(), well and good, but if independently then it will cause a fault. So it looks a fair enough solution to me.
yikes! That is very wrong. Coming up a patch which moves out the cgroup_free_controller from libcgroup.h and makes it static. It should never ever be called from outside.
Reopening this, since this is still needs to be fixed with a better solution.