Patchwork loader: memory leak in rom_add_file() on error path

login
register
mail settings
Submitter Isaku Yamahata
Date Jan. 24, 2011, 10 a.m.
Message ID <6415008f38500f490594eef803cf910f0bb5f46c.1295863213.git.yamahata@valinux.co.jp>
Download mbox | patch
Permalink /patch/80171/
State New
Headers show

Comments

Isaku Yamahata - Jan. 24, 2011, 10 a.m.
fix memory leak in rom_add_file().

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
 hw/loader.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Patch

diff --git a/hw/loader.c b/hw/loader.c
index 35d792e..6cba8c5 100644
--- a/hw/loader.c
+++ b/hw/loader.c
@@ -618,6 +618,8 @@  int rom_add_file(const char *file, const char *fw_dir,
 err:
     if (fd != -1)
         close(fd);
+    qemu_free(rom->fw_file);
+    qemu_free(rom->fw_dir);
     qemu_free(rom->data);
     qemu_free(rom->path);
     qemu_free(rom->name);