mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 17:23:56 -06:00
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>
This commit is contained in:
parent
72674db080
commit
54c52ec719
1 changed files with 1 additions and 2 deletions
|
@ -884,7 +884,6 @@ static void loongarch_init(MachineState *machine)
|
||||||
const CPUArchIdList *possible_cpus;
|
const CPUArchIdList *possible_cpus;
|
||||||
MachineClass *mc = MACHINE_GET_CLASS(machine);
|
MachineClass *mc = MACHINE_GET_CLASS(machine);
|
||||||
CPUState *cpu;
|
CPUState *cpu;
|
||||||
char *ramName = NULL;
|
|
||||||
|
|
||||||
if (!cpu_model) {
|
if (!cpu_model) {
|
||||||
cpu_model = LOONGARCH_CPU_TYPE_NAME("la464");
|
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++) {
|
for (i = 1; i < nb_numa_nodes; i++) {
|
||||||
MemoryRegion *nodemem = g_new(MemoryRegion, 1);
|
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,
|
memory_region_init_alias(nodemem, NULL, ramName, machine->ram,
|
||||||
offset, numa_info[i].node_mem);
|
offset, numa_info[i].node_mem);
|
||||||
memory_region_add_subregion(address_space_mem, phyAddr, nodemem);
|
memory_region_add_subregion(address_space_mem, phyAddr, nodemem);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue