qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH-for-5.2 v2] hw/rx/rx-gdbsim: Fix memory leak


From: Philippe Mathieu-Daudé
Subject: [PATCH-for-5.2 v2] hw/rx/rx-gdbsim: Fix memory leak
Date: Fri, 30 Oct 2020 14:49:18 +0100

As load_device_tree() returns allocated memory,
we need to free it.

Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Fixes: bda19d7bb56 ("hw/rx: Add RX GDB simulator")
Reported-by: Coverity (CID 1432307: RESOURCE_LEAK)
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
v2: NULL-initialize (Richard)
---
 hw/rx/rx-gdbsim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/rx/rx-gdbsim.c b/hw/rx/rx-gdbsim.c
index 417ec0564b3..d70865962e8 100644
--- a/hw/rx/rx-gdbsim.c
+++ b/hw/rx/rx-gdbsim.c
@@ -122,7 +122,7 @@ static void rx_gdbsim_init(MachineState *machine)
         if (dtb_filename) {
             ram_addr_t dtb_offset;
             int dtb_size;
-            void *dtb;
+            g_autofree void *dtb = NULL;
 
             dtb = load_device_tree(dtb_filename, &dtb_size);
             if (dtb == NULL) {
-- 
2.26.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]