summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-03-08 22:21:54 +0900
committerSven Eden <yamakuzure@gmx.net>2018-06-28 09:23:09 +0200
commit7cf7f1a0c1238531307c170b3cf6940d77511c11 (patch)
tree660cfad4eace9fdef0fff7db880ad8bd405b1df0
parent5433f4c65b85959c9a0d442308cec35a55f4f159 (diff)
core: do not free heap-allocated strings (#8391)
Fixes #8387. (cherry picked from commit 5cbaad2f6795088db56063d20695c6444595822f)
-rw-r--r--src/core/mount-setup.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/core/mount-setup.c b/src/core/mount-setup.c
index 8fb0a1dea..ea6f04f52 100644
--- a/src/core/mount-setup.c
+++ b/src/core/mount-setup.c
@@ -263,6 +263,7 @@ int mount_setup_early(void) {
int mount_cgroup_controllers(char ***join_controllers) {
_cleanup_set_free_free_ Set *controllers = NULL;
+ bool has_argument = !!join_controllers;
int r;
if (!cg_is_legacy_wanted())
@@ -270,7 +271,7 @@ int mount_cgroup_controllers(char ***join_controllers) {
/* Mount all available cgroup controllers that are built into the kernel. */
- if (!join_controllers)
+ if (!has_argument)
/* The defaults:
* mount "cpu" + "cpuacct" together, and "net_cls" + "net_prio".
*
@@ -315,7 +316,8 @@ int mount_cgroup_controllers(char ***join_controllers) {
t = set_remove(controllers, *i);
if (!t) {
- free(*i);
+ if (has_argument)
+ free(*i);
continue;
}
}