aboutsummaryrefslogtreecommitdiff
path: root/backends/hostmem-memfd.c
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@linaro.org>2023-11-20 12:59:15 +0100
committerPhilippe Mathieu-Daudé <philmd@linaro.org>2024-01-05 16:20:15 +0100
commit2d7a1eb6e65d5dd32cb9943b6fb3c81d206cd61f (patch)
tree0c7ddc0649eb8230b06e77442da1e3a24e4a4479 /backends/hostmem-memfd.c
parent9583a905793986d9018fe1fbb17d17fb4f0d76dd (diff)
backends: Use g_autofree in HostMemoryBackendClass::alloc() handlers
In preparation of having HostMemoryBackendClass::alloc() handlers return a boolean, have them use g_autofree. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Reviewed-by: Gavin Shan <gshan@redhat.com> Message-Id: <20231120213301.24349-15-philmd@linaro.org>
Diffstat (limited to 'backends/hostmem-memfd.c')
-rw-r--r--backends/hostmem-memfd.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c
index 3fc85c3db8..db28ab5a56 100644
--- a/backends/hostmem-memfd.c
+++ b/backends/hostmem-memfd.c
@@ -35,8 +35,8 @@ static void
memfd_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
{
HostMemoryBackendMemfd *m = MEMORY_BACKEND_MEMFD(backend);
+ g_autofree char *name = NULL;
uint32_t ram_flags;
- char *name;
int fd;
if (!backend->size) {
@@ -57,7 +57,6 @@ memfd_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
ram_flags |= backend->reserve ? 0 : RAM_NORESERVE;
memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend), name,
backend->size, ram_flags, fd, 0, errp);
- g_free(name);
}
static bool