diff options
author | Wen Yang <wenyang@linux.alibaba.com> | 2020-07-01 04:45:33 +0800 |
---|---|---|
committer | The Plumber <50238977+systemd-rhel-bot@users.noreply.github.com> | 2020-11-02 15:55:17 +0100 |
commit | 1c8d1c3bbdf8bdfb2ee4f85b9f559f54c6e4cac4 (patch) | |
tree | bc60c40c249241c647f2a01b6186801fefc10374 | |
parent | 9c0ed82f661a2296784970678746b0b4f130870e (diff) | |
download | systemd-1c8d1c3bbdf8bdfb2ee4f85b9f559f54c6e4cac4.tar.gz |
mount-setup: fix segfault in mount_cgroup_controllers when using gcc9 compiler
According to the documentation:
https://gcc.gnu.org/gcc-9/porting_to.html#complit
The 'join_controllers' that relied on the extended lifetime needs
to be fixed, move the compound literals to the function scope it
need to accessible in.
Resolves: #1868877
-rw-r--r-- | src/core/mount-setup.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/core/mount-setup.c b/src/core/mount-setup.c index 16880e6157..a6594580e5 100644 --- a/src/core/mount-setup.c +++ b/src/core/mount-setup.c @@ -237,20 +237,22 @@ int mount_cgroup_controllers(char ***join_controllers) { if (!cg_is_legacy_wanted()) return 0; + /* The defaults: + * mount "cpu" + "cpuacct" together, and "net_cls" + "net_prio". + * + * We'd like to add "cpuset" to the mix, but "cpuset" doesn't really + * work for groups with no initialized attributes. + */ + char ***default_join_controllers = (char**[]) { + STRV_MAKE("cpu", "cpuacct"), + STRV_MAKE("net_cls", "net_prio"), + NULL, + }; + /* Mount all available cgroup controllers that are built into the kernel. */ if (!has_argument) - /* The defaults: - * mount "cpu" + "cpuacct" together, and "net_cls" + "net_prio". - * - * We'd like to add "cpuset" to the mix, but "cpuset" doesn't really - * work for groups with no initialized attributes. - */ - join_controllers = (char**[]) { - STRV_MAKE("cpu", "cpuacct"), - STRV_MAKE("net_cls", "net_prio"), - NULL, - }; + join_controllers = default_join_controllers; r = cg_kernel_controllers(&controllers); if (r < 0) |