QEMU-Devel Archive mirror
 help / color / mirror / Atom feed
From: "R.Samarasekara" <rsamarnz@gmail.com>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, gaosong@loongson.cn, raj3sr@gmail.com,
	"R.Samarasekara" <rsamarnz@gmail.com>
Subject: [PATCH] hw/loongarch/virt.c: Fixes memory leak in ramName during loop iterations
Date: Fri, 10 May 2024 01:28:02 +1200	[thread overview]
Message-ID: <20240509132802.247147-1-rsamarnz@gmail.com> (raw)

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



             reply	other threads:[~2024-05-09 13:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-09 13:28 R.Samarasekara [this message]
2024-05-10  8:40 ` [PATCH] hw/loongarch/virt.c: Fixes memory leak in ramName during loop iterations Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240509132802.247147-1-rsamarnz@gmail.com \
    --to=rsamarnz@gmail.com \
    --cc=gaosong@loongson.cn \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=raj3sr@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).