diff options
author | Song Gao <gaosong@loongson.cn> | 2024-05-07 10:22:39 +0800 |
---|---|---|
committer | Philippe Mathieu-Daudé <philmd@linaro.org> | 2024-05-09 00:07:21 +0200 |
commit | 54c52ec719fb8c83bbde54cb87b58688ab27c166 (patch) | |
tree | 9f0c5ed5d2a7748ff561b700ef4684d4a7315d25 /hw | |
parent | 72674db080bcdf2fd66b2a538379ee6000f5b113 (diff) | |
download | qemu-54c52ec719fb8c83bbde54cb87b58688ab27c166.zip qemu-54c52ec719fb8c83bbde54cb87b58688ab27c166.tar.gz qemu-54c52ec719fb8c83bbde54cb87b58688ab27c166.tar.bz2 |
hw/loongarch/virt: Fix memory leak
The char pointer 'ramName' point to a block of memory,
but never free it. Use 'g_autofree' to automatically free it.
Resolves: Coverity CID 1544773
Fixes: 0cf1478d6 ("hw/loongarch: Add numa support")
Signed-off-by: Song Gao <gaosong@loongson.cn>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240507022239.3113987-1-gaosong@loongson.cn>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/loongarch/virt.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index 504e1fb..69924a8 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -884,7 +884,6 @@ static void loongarch_init(MachineState *machine) const CPUArchIdList *possible_cpus; MachineClass *mc = MACHINE_GET_CLASS(machine); CPUState *cpu; - char *ramName = NULL; if (!cpu_model) { cpu_model = LOONGARCH_CPU_TYPE_NAME("la464"); @@ -943,7 +942,7 @@ static void loongarch_init(MachineState *machine) for (i = 1; i < nb_numa_nodes; i++) { MemoryRegion *nodemem = g_new(MemoryRegion, 1); - ramName = g_strdup_printf("loongarch.node%d.ram", i); + g_autofree char *ramName = g_strdup_printf("loongarch.node%d.ram", i); memory_region_init_alias(nodemem, NULL, ramName, machine->ram, offset, numa_info[i].node_mem); memory_region_add_subregion(address_space_mem, phyAddr, nodemem); |