[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 19/26] hw/loongarch/virt: Fix memory leak
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 19/26] hw/loongarch/virt: Fix memory leak |
Date: |
Wed, 8 May 2024 19:45:03 +0200 |
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>
---
hw/loongarch/virt.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
index 504e1fb349..69924a8734 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);
--
2.41.0
- Re: [PULL 05/26] hw/remote/vfio-user: Fix config space access byte order, (continued)
- [PULL 12/26] hw/i386/x86: Eliminate two if statements in x86_bios_rom_init(), Philippe Mathieu-Daudé, 2024/05/08
- [PULL 14/26] hw/i386/x86: Don't leak "isa-bios" memory regions, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 10/26] hw/i386/Kconfig: Allow to compile Q35 without FDC_ISA, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 08/26] system/physmem: Per-AddressSpace bounce buffering, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 11/26] hw/i386: Add the possibility to use i440fx and isapc without FDC, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 15/26] hw/usb/dev-network: Remove unused struct 'rndis_config_parameter', Philippe Mathieu-Daudé, 2024/05/08
- [PULL 16/26] hw/gpio: Handle clock migration in STM32L4x5 gpios, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 17/26] hw/ppc: Deprecate 'ref405ep' machine and 405 CPUs, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 18/26] hw/loongarch: move memory map to boot.c, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 19/26] hw/loongarch/virt: Fix memory leak,
Philippe Mathieu-Daudé <=
- [PULL 20/26] hw/loongarch: Rename LOONGARCH_MACHINE with LOONGARCH_VIRT_MACHINE, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 23/26] hw/intc/loongarch_ipi: Remove pointless MAX_CPU check, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 22/26] hw/mips/loongson3_virt: Emulate suspend function, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 24/26] hw/intc/loongarch_ipi: Rename as loongson_ipi, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 21/26] hw/loongarch: Rename LoongArchMachineState with LoongArchVirtMachineState, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 25/26] hw/intc/loongson_ipi: Implement IOCSR address space for MIPS, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 26/26] misc: Use QEMU header path relative to include/ directory, Philippe Mathieu-Daudé, 2024/05/08