summaryrefslogtreecommitdiff
path: root/src/core/dbus-manager.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-04-02 16:06:07 +0200
committerGitHub <noreply@github.com>2019-04-02 16:06:07 +0200
commit237ebf61e2634b68d3f32e1e965bab98468821e5 (patch)
tree54538b9714ee870d570bc24ad3b3f32793e625a0 /src/core/dbus-manager.c
parent84ce204a93841776f022712d11219c616e585192 (diff)
parent8cc6727a5a126266eb5582ccf85833e2acfeed62 (diff)
downloadsystemd-237ebf61e2634b68d3f32e1e965bab98468821e5.tar.gz
Merge pull request #12013 from yuwata/fix-switchroot-11997
core: on switching root do not emit device state change based on enumeration results
Diffstat (limited to 'src/core/dbus-manager.c')
-rw-r--r--src/core/dbus-manager.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index 475c9194ac..1c1f4dcd06 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -1492,7 +1492,7 @@ static int method_kexec(sd_bus_message *message, void *userdata, sd_bus_error *e
}
static int method_switch_root(sd_bus_message *message, void *userdata, sd_bus_error *error) {
- char *ri = NULL, *rt = NULL;
+ _cleanup_free_ char *ri = NULL, *rt = NULL;
const char *root, *init;
Manager *m = userdata;
struct statvfs svfs;
@@ -1564,17 +1564,12 @@ static int method_switch_root(sd_bus_message *message, void *userdata, sd_bus_er
if (!isempty(init)) {
ri = strdup(init);
- if (!ri) {
- free(rt);
+ if (!ri)
return -ENOMEM;
- }
}
- free(m->switch_root);
- m->switch_root = rt;
-
- free(m->switch_root_init);
- m->switch_root_init = ri;
+ free_and_replace(m->switch_root, rt);
+ free_and_replace(m->switch_root_init, ri);
m->objective = MANAGER_SWITCH_ROOT;