From d8acdf54f685fc30329842d6213eb3eacbd02be9 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Sat, 17 Feb 2018 19:47:23 +0100 Subject: [PATCH] cgfsng: cg_legacy_set_data() Signed-off-by: Christian Brauner --- src/lxc/cgroups/cgfsng.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c index aa6ca129c..a892e7fc7 100644 --- a/src/lxc/cgroups/cgfsng.c +++ b/src/lxc/cgroups/cgfsng.c @@ -2660,13 +2660,13 @@ out: return ret; } -/* - * Called from setup_limits - here we have the container's cgroup_data because - * we created the cgroups +/* Called from setup_limits - here we have the container's cgroup_data because + * we created the cgroups. */ static int cg_legacy_set_data(const char *filename, const char *value, struct cgfsng_handler_data *d) { + size_t len; char *fullpath, *p; /* "b|c <2^64-1>:<2^64-1> r|w|m" = 47 chars max */ char converted_value[50]; @@ -2674,9 +2674,11 @@ static int cg_legacy_set_data(const char *filename, const char *value, int ret = 0; char *controller = NULL; - controller = alloca(strlen(filename) + 1); + len = strlen(filename); + controller = alloca(len + 1); strcpy(controller, filename); - if ((p = strchr(controller, '.')) != NULL) + p = strchr(controller, '.'); + if (p) *p = '\0'; if (strcmp("devices.allow", filename) == 0 && value[0] == '/') { @@ -2684,7 +2686,6 @@ static int cg_legacy_set_data(const char *filename, const char *value, if (ret < 0) return ret; value = converted_value; - } h = get_hierarchy(controller); @@ -2694,7 +2695,7 @@ static int cg_legacy_set_data(const char *filename, const char *value, "driver or not enabled on the cgroup hierarchy", controller); errno = ENOENT; - return -1; + return -ENOENT; } fullpath = must_make_path(h->fullcgpath, filename, NULL); -- 2.47.3