diff options
author | Evgeny Vereshchagin <evvers@ya.ru> | 2018-12-24 00:29:56 +0100 |
---|---|---|
committer | The Plumber <50238977+systemd-rhel-bot@users.noreply.github.com> | 2019-11-01 10:50:19 +0100 |
commit | c4b02a7b15c21db44542d0a136d032f8098985b8 (patch) | |
tree | 962fe43764a0fec8f2f960c4a0d3b630c4dc5a54 | |
parent | ebe93460ef5ae3744c4b627361f4dc5815cffc13 (diff) | |
download | systemd-c4b02a7b15c21db44542d0a136d032f8098985b8.tar.gz |
journal: rely on _cleanup_free_ to free a temporary string used in client_context_read_cgroup
Closes https://github.com/systemd/systemd/issues/11253.
(cherry picked from commit ef30f7cac18a810814ada7e6a68a31d48cc9fccd)
(cherry picked from commit 3513426adcecc322937635c11ebb89f174f849ed)
Resolves: #1767716
-rw-r--r-- | src/journal/journald-context.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/journal/journald-context.c b/src/journal/journald-context.c index dba3525ed8..4f1278492f 100644 --- a/src/journal/journald-context.c +++ b/src/journal/journald-context.c @@ -276,7 +276,7 @@ static int client_context_read_label( } static int client_context_read_cgroup(Server *s, ClientContext *c, const char *unit_id) { - char *t = NULL; + _cleanup_free_ char *t = NULL; int r; assert(c); @@ -284,7 +284,6 @@ static int client_context_read_cgroup(Server *s, ClientContext *c, const char *u /* Try to acquire the current cgroup path */ r = cg_pid_get_path_shifted(c->pid, s->cgroup_root, &t); if (r < 0 || empty_or_root(t)) { - /* We use the unit ID passed in as fallback if we have nothing cached yet and cg_pid_get_path_shifted() * failed or process is running in a root cgroup. Zombie processes are automatically migrated to root cgroup * on cgroupsv1 and we want to be able to map log messages from them too. */ @@ -298,10 +297,8 @@ static int client_context_read_cgroup(Server *s, ClientContext *c, const char *u } /* Let's shortcut this if the cgroup path didn't change */ - if (streq_ptr(c->cgroup, t)) { - free(t); + if (streq_ptr(c->cgroup, t)) return 0; - } free_and_replace(c->cgroup, t); |