[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-8.2.5 04/21] hw/loongarch/virt: Fix memory leak
From: |
Michael Tokarev |
Subject: |
[Stable-8.2.5 04/21] hw/loongarch/virt: Fix memory leak |
Date: |
Mon, 27 May 2024 10:24:14 +0300 |
From: Song Gao <gaosong@loongson.cn>
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>
(cherry picked from commit 54c52ec719fb8c83bbde54cb87b58688ab27c166)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: context fixup in hw/loongarch/virt.c due to missing-in-8.2
v9.0.0-266-gd771ca1c10 "hw/loongarch: Move boot functions to boot.c")
diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
index 4b7dc67a2d..713ba26dff 100644
--- a/hw/loongarch/virt.c
+++ b/hw/loongarch/virt.c
@@ -749,7 +749,6 @@ static void loongarch_init(MachineState *machine)
const CPUArchIdList *possible_cpus;
MachineClass *mc = MACHINE_GET_CLASS(machine);
CPUState *cpu;
- char *ramName = NULL;
struct loaderparams loaderparams = { };
if (!cpu_model) {
@@ -800,7 +799,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);
--
2.39.2
- [Stable-8.2.5 00/21] Patch Round-up for stable 8.2.5, freeze on 2024-06-07, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 01/21] target/i386: Give IRQs a chance when resetting HF_INHIBIT_IRQ_MASK, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 02/21] target/sparc: Fix FEXPAND, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 06/21] target/i386: fix operand size for DATA16 REX.W POPCNT, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 08/21] target/i386: fix feature dependency for WAITPKG, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 04/21] hw/loongarch/virt: Fix memory leak,
Michael Tokarev <=
- [Stable-8.2.5 07/21] target/i386: rdpkru/wrpkru are no-prefix instructions, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 10/21] configure: Fix error message when C compiler is not working, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 03/21] target/sparc: Fix FMUL8x16, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 05/21] hw/remote/vfio-user: Fix config space access byte order, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 12/21] ui/gtk: Check if fence_fd is equal to or greater than 0, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 09/21] configure: quote -D options that are passed through to meson, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 11/21] ui/gtk: Fix mouse/motion event scaling issue with GTK display backend, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 16/21] target/loongarch/kvm: Fix VM recovery from disk failures, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 15/21] hw/core/machine: move compatibility flags for VirtIO-net USO to machine 8.1, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 13/21] tcg/loongarch64: Fill out tcg_out_{ld, st} for vector regs, Michael Tokarev, 2024/05/27