summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGonglei <arei.gonglei@huawei.com>2015-03-05 11:05:20 +0800
committerMichael Tokarev <mjt@tls.msk.ru>2015-04-30 16:06:18 +0300
commit4d850406a859d3a5dcfca74eb9caa76ccc064ab3 (patch)
tree10a9347b4e321eecb6c1520a8457bc570b0c8f74
parentfee068e4f190a36ef3bda9aa7c802f90434ef8e5 (diff)
downloadhqemu-4d850406a859d3a5dcfca74eb9caa76ccc064ab3.zip
hqemu-4d850406a859d3a5dcfca74eb9caa76ccc064ab3.tar.gz
microblaze: fix memory leak
When not assign a -dtb argument, the variable dtb_filename storage returned from qemu_find_file(), which should be freed after use. Alternatively we define a local variable filename, with 'char *' type, free after use. Signed-off-by: Gonglei <arei.gonglei@huawei.com> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
-rw-r--r--hw/microblaze/boot.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/hw/microblaze/boot.c b/hw/microblaze/boot.c
index 38c59db..4c44317 100644
--- a/hw/microblaze/boot.c
+++ b/hw/microblaze/boot.c
@@ -113,15 +113,15 @@ void microblaze_load_kernel(MicroBlazeCPU *cpu, hwaddr ddr_base,
const char *kernel_filename;
const char *kernel_cmdline;
const char *dtb_arg;
+ char *filename = NULL;
machine_opts = qemu_get_machine_opts();
kernel_filename = qemu_opt_get(machine_opts, "kernel");
kernel_cmdline = qemu_opt_get(machine_opts, "append");
dtb_arg = qemu_opt_get(machine_opts, "dtb");
- if (dtb_arg) { /* Preference a -dtb argument */
- dtb_filename = dtb_arg;
- } else { /* default to pcbios dtb as passed by machine_init */
- dtb_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, dtb_filename);
+ /* default to pcbios dtb as passed by machine_init */
+ if (!dtb_arg) {
+ filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, dtb_filename);
}
boot_info.machine_cpu_reset = machine_cpu_reset;
@@ -203,7 +203,8 @@ void microblaze_load_kernel(MicroBlazeCPU *cpu, hwaddr ddr_base,
boot_info.initrd_start,
boot_info.initrd_end,
kernel_cmdline,
- dtb_filename);
+ /* Preference a -dtb argument */
+ dtb_arg ? dtb_arg : filename);
}
-
+ g_free(filename);
}
OpenPOWER on IntegriCloud