Skip to contentSkip to conversation

hw/arm/digic: Fix memory leak reported by Coverity

PATCH In review Stefan Weil 2 participants 3 messages Mar 14, 2015 – Sep 25, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/arm/digic: Fix memory leak reported by Coverity

---
 hw/arm/digic_boards.c |    1 +
 1 file changed, 1 insertion(+)
hw/arm/digic_boards.c +1 -0
index 7114c36..ad70f7b 100644
@@ -109,6 +109,7 @@ static void digic_load_rom(DigicBoardState *s, hwaddr addr,
         }
 
         rom_size = load_image_targphys(fn, addr, max_size);
+        g_free(fn);
         if (rom_size < 0 || rom_size > max_size) {
             error_report("Couldn't load rom image '%s'.", filename);
             exit(1);
Signature · 1 line
1.7.10.4
#1 lore raw

Am 14.03.2015 um 11:19 schrieb Stefan Weil:

Quoted 11 lines
---
 hw/arm/digic_boards.c |    1 +
 1 file changed, 1 insertion(+)
hw/arm/digic_boards.c +0 -0
index 7114c36..ad70f7b 100644

hw/arm/digic_boards.c static void digic_load_rom(DigicBoardState *s, hwaddr addr, · line 115

Quoted 7 lines
hw/arm/digic_boards.c +1 -0
@@ -109,6 +109,7 @@ static void digic_load_rom(DigicBoardState *s, hwaddr addr,
         }
 
         rom_size = load_image_targphys(fn, addr, max_size);
+        g_free(fn);
         if (rom_size < 0 || rom_size > max_size) {
             error_report("Couldn't load rom image '%s'.", filename);
             exit(1);

Ping? Maybe this old patch can be applied to qemu-trivial.

fn = qemu_find_file() allocates memory, so g_free is needed.

Regards
Stefan

#2 lore raw
Quoted 22 lines · Stefan Weil

Am 14.03.2015 um 11:19 schrieb Stefan Weil:

Quoted 11 lines
---
 hw/arm/digic_boards.c |    1 +
 1 file changed, 1 insertion(+)
hw/arm/digic_boards.c +0 -0
index 7114c36..ad70f7b 100644

hw/arm/digic_boards.c static void digic_load_rom(DigicBoardState *s, hwaddr addr, · line 115

Quoted 7 lines
hw/arm/digic_boards.c +1 -0
@@ -109,6 +109,7 @@ static void digic_load_rom(DigicBoardState *s, hwaddr addr,
         }
 
         rom_size = load_image_targphys(fn, addr, max_size);
+        g_free(fn);
         if (rom_size < 0 || rom_size > max_size) {
             error_report("Couldn't load rom image '%s'.", filename);
             exit(1);

Ping? Maybe this old patch can be applied to qemu-trivial.

Quoted 1 line

fn = qemu_find_file() allocates memory, so g_free is needed.

No, this was fixed by commit 6e05a12f8f7f32a3 so although this patch still textually applies it would introduce a double-free.

thanks
-- PMM