From e83c4d178b585df0287f00aecd2a7b5c3b0c140e Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 22 Jun 2022 16:20:30 +0900 Subject: [PATCH 1/2] core: drop unnecessary free As reset_arguments() frees the string. Follow-up for 919ea64f69f710840c1bc93f0f7cb7c51aae45d0. --- src/core/main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/main.c b/src/core/main.c index 18ba2b063c..b796dc8c2a 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -3007,7 +3007,6 @@ finish: /* Cleanup watchdog_device strings for valgrind. We need them * in become_shutdown() so normally we cannot free them yet. */ watchdog_free_device(); - arg_watchdog_device = mfree(arg_watchdog_device); reset_arguments(); return retval; } From 82d7a151db3f504fee705bcd0ded2fa0d64eafb2 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 22 Jun 2022 16:22:39 +0900 Subject: [PATCH 2/2] core: close watchdog device if watchdog device is unspecified now If a watchdog device was specified previously, and unspecified later and PID1 is reloaded, then we need to close the device. --- src/core/main.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/core/main.c b/src/core/main.c index b796dc8c2a..7cd13b9e13 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -2118,11 +2118,9 @@ static int initialize_runtime( write_container_id(); } - if (arg_watchdog_device) { - r = watchdog_set_device(arg_watchdog_device); - if (r < 0) - log_warning_errno(r, "Failed to set watchdog device to %s, ignoring: %m", arg_watchdog_device); - } + r = watchdog_set_device(arg_watchdog_device); + if (r < 0) + log_warning_errno(r, "Failed to set watchdog device to %s, ignoring: %m", arg_watchdog_device); } else { _cleanup_free_ char *p = NULL;