cgroups: prevent NULL pointer deref

parent 8f45c49b
...@@ -3212,15 +3212,17 @@ static bool __cgfsng_delegate_controllers(struct cgroup_ops *ops, const char *cg ...@@ -3212,15 +3212,17 @@ static bool __cgfsng_delegate_controllers(struct cgroup_ops *ops, const char *cg
{ {
__do_close int dfd_final = -EBADF; __do_close int dfd_final = -EBADF;
__do_free char *add_controllers = NULL, *copy = NULL; __do_free char *add_controllers = NULL, *copy = NULL;
struct hierarchy *unified = ops->unified;
int dfd_cur = unified->dfd_base;
int ret;
size_t full_len = 0; size_t full_len = 0;
struct hierarchy *unified;
int dfd_cur, ret;
char *cur; char *cur;
char **it; char **it;
if (!ops->hierarchies || !pure_unified_layout(ops) || if (!ops->hierarchies || !pure_unified_layout(ops))
!unified->controllers[0]) return true;
unified = ops->unified;
if (!unified->controllers[0])
return true; return true;
/* For now we simply enable all controllers that we have detected by /* For now we simply enable all controllers that we have detected by
...@@ -3252,6 +3254,7 @@ static bool __cgfsng_delegate_controllers(struct cgroup_ops *ops, const char *cg ...@@ -3252,6 +3254,7 @@ static bool __cgfsng_delegate_controllers(struct cgroup_ops *ops, const char *cg
* intentional because of the cgroup2 delegation model. It enforces * intentional because of the cgroup2 delegation model. It enforces
* that leaf cgroups don't have any controllers enabled for delegation. * that leaf cgroups don't have any controllers enabled for delegation.
*/ */
dfd_cur = unified->dfd_base;
lxc_iterate_parts(cur, copy, "/") { lxc_iterate_parts(cur, copy, "/") {
/* /*
* Even though we vetted the paths when we parsed the config * Even though we vetted the paths when we parsed the config
......
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