From d90a05b68faf38eb3b67664ed2a7bbd263d19f2e Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 23 Feb 2024 17:22:34 +0100 Subject: [PATCH] vmspawn: drop "const" from string we free I am a bit surprised this compiled at all... --- src/vmspawn/vmspawn.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/vmspawn/vmspawn.c b/src/vmspawn/vmspawn.c index f67c6a51bcc..9d8c063e98e 100644 --- a/src/vmspawn/vmspawn.c +++ b/src/vmspawn/vmspawn.c @@ -639,7 +639,12 @@ static int cmdline_add_vsock(char ***cmdline, int vsock_fd) { return 0; } -static int start_tpm(sd_bus *bus, const char *scope, const char *tpm, const char **ret_state_tempdir) { +static int start_tpm( + sd_bus *bus, + const char *scope, + const char *swtpm, + char **ret_state_tempdir) { + _cleanup_(rm_rf_physical_and_freep) char *state_dir = NULL; _cleanup_free_ char *scope_prefix = NULL; _cleanup_(socket_service_pair_done) SocketServicePair ssp = { @@ -649,7 +654,7 @@ static int start_tpm(sd_bus *bus, const char *scope, const char *tpm, const char assert(bus); assert(scope); - assert(tpm); + assert(swtpm); assert(ret_state_tempdir); r = unit_name_to_prefix(scope, &scope_prefix); @@ -674,7 +679,7 @@ static int start_tpm(sd_bus *bus, const char *scope, const char *tpm, const char if (!ssp.listen_address) return log_oom(); - ssp.exec_start = strv_new(tpm, "socket", "--tpm2", "--tpmstate"); + ssp.exec_start = strv_new(swtpm, "socket", "--tpm2", "--tpmstate"); if (!ssp.exec_start) return log_oom(); @@ -691,7 +696,6 @@ static int start_tpm(sd_bus *bus, const char *scope, const char *tpm, const char return r; *ret_state_tempdir = TAKE_PTR(state_dir); - return 0; } @@ -1457,7 +1461,7 @@ static int run_virtual_machine(int kvm_device_fd, int vhost_device_fd) { } } - _cleanup_free_ const char *tpm_state_tempdir = NULL; + _cleanup_free_ char *tpm_state_tempdir = NULL; if (swtpm) { _cleanup_free_ char *escaped_state_dir = NULL; -- 2.47.3