lxc/0038-check-cgroup-path-empty-while-setting-freezer.patch
openeuler-sync-bot 00993408ce !509 [sync] PR-508: check cgroup path empty while setting freezer
* check cgroup path empty while setting freezer
2023-12-20 06:08:26 +00:00

35 lines
1.1 KiB
Diff

From 6085c67cce5d4c5495e9a585d137b79af1b1598e Mon Sep 17 00:00:00 2001
From: jikai <jikai11@huawei.com>
Date: Tue, 19 Dec 2023 15:41:05 +0800
Subject: [PATCH] check cgroup path empty while setting freezer
Signed-off-by: jikai <jikai11@huawei.com>
---
src/lxc/start.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/lxc/start.c b/src/lxc/start.c
index ec64546..c01eb9b 100644
--- a/src/lxc/start.c
+++ b/src/lxc/start.c
@@ -1020,9 +1020,15 @@ static int get_all_pids(struct cgroup_ops *cg_ops, pid_t **pids, size_t *len)
static int set_cgroup_freezer(struct cgroup_ops *cg_ops, const char *value)
{
char *fullpath;
+ const char *cgroup_path;
int ret;
- fullpath = must_make_path(cg_ops->get_cgroup_full_path(cg_ops, "freezer"), "freezer.state", NULL);
+ cgroup_path = cg_ops->get_cgroup_full_path(cg_ops, "freezer");
+ if (cgroup_path == NULL) {
+ return -1;
+ }
+
+ fullpath = must_make_path(cgroup_path, "freezer.state", NULL);
ret = lxc_write_to_file(fullpath, value, strlen(value), false, 0666);
free(fullpath);
return ret;
--
2.33.0