qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hw/loongarch/virt.c: Fixes memory leak in ramName during loop iterations
@ 2024-05-09 13:28 R.Samarasekara
  2024-05-10  8:40 ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 2+ messages in thread
From: R.Samarasekara @ 2024-05-09 13:28 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, gaosong, raj3sr, R.Samarasekara

This patch fixes a memory leak in the ramName variable within the
hw/loongarch/virt.c file. The leak occurs due to repeated calls to
g_strdup_printf within a loop, causing memory allocated for ramName on
previous iterations to be unfreed.

Signed-off-by: R.Samarasekara <rsamarnz@gmail.com>
---
 hw/loongarch/virt.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c
index c0999878df..1fe02f8501 100644
--- a/hw/loongarch/virt.c
+++ b/hw/loongarch/virt.c
@@ -954,6 +954,7 @@ static void loongarch_init(MachineState *machine)
         fdt_add_memory_node(machine, phyAddr, numa_info[i].node_mem, i);
         offset += numa_info[i].node_mem;
         phyAddr += numa_info[i].node_mem;
+        g_free(ramName);
     }
 
     /* initialize device memory address space */
-- 
2.40.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-05-10  8:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-09 13:28 [PATCH] hw/loongarch/virt.c: Fixes memory leak in ramName during loop iterations R.Samarasekara
2024-05-10  8:40 ` Philippe Mathieu-Daudé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).