mirror of
https://github.com/qemu/qemu.git
synced 2026-07-08 17:46:17 +00:00
system/vl: Free allocate memory for pid file name in case realpath() failed
In case realpath() fails, the code returns early in the function
qemu_maybe_daemonize(), without freeing the allocated memory. Add
a g_free() here to fix it.
And while we're at it, also free the memory in the qemu_unlink_pidfile()
function - it's not that important since QEMU is going to terminate anyway,
but some malloc sanitizers might still complain if we don't free it.
Fixes: dee2a4d4d2 ("vl: defuse PID file path resolve error")
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20260518114514.684401-1-thuth@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
This commit is contained in:
committed by
Philippe Mathieu-Daudé
parent
510899e681
commit
59f9e694af
@@ -1634,6 +1634,8 @@ static void qemu_unlink_pidfile(Notifier *n, void *data)
|
||||
|
||||
upn = DO_UPCAST(struct UnlinkPidfileNotifier, notifier, n);
|
||||
unlink(upn->pid_file_realpath);
|
||||
g_free(upn->pid_file_realpath);
|
||||
upn->pid_file_realpath = NULL;
|
||||
}
|
||||
|
||||
static const QEMUOption *lookup_opt(int argc, char **argv,
|
||||
@@ -2672,6 +2674,7 @@ static void qemu_maybe_daemonize(const char *pid_file)
|
||||
warn_report("not removing PID file on exit: cannot resolve PID "
|
||||
"file path: %s: %s", pid_file, strerror(errno));
|
||||
}
|
||||
g_free(pid_file_realpath);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user