aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergio Lopez <slp@redhat.com>2019-11-12 17:34:23 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2019-11-19 10:00:36 +0100
commitc3157b74c47f886f99df752500f7cf76e7a287dd (patch)
treeca4fd82bc879a945a135199f2c36b802317e9491
parentb73f059cf2dce327f4f5936a1e6d4d7b898c6a71 (diff)
downloadqemu-c3157b74c47f886f99df752500f7cf76e7a287dd.tar.gz
microvm: fix memory leak in microvm_fix_kernel_cmdline
In microvm_fix_kernel_cmdline(), fw_cfg_modify_string() is duplicating cmdline instead of taking ownership of it. Free it afterwards to avoid leaking it. Reported-by: Coverity (CID 1407218) Suggested-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Sergio Lopez <slp@redhat.com> Message-Id: <20191112163423.91884-1-slp@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--hw/i386/microvm.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
index 8aacd6c8d12..def37e60f79 100644
--- a/hw/i386/microvm.c
+++ b/hw/i386/microvm.c
@@ -331,6 +331,8 @@ static void microvm_fix_kernel_cmdline(MachineState *machine)
fw_cfg_modify_i32(x86ms->fw_cfg, FW_CFG_CMDLINE_SIZE, strlen(cmdline) + 1);
fw_cfg_modify_string(x86ms->fw_cfg, FW_CFG_CMDLINE_DATA, cmdline);
+
+ g_free(cmdline);
}
static void microvm_machine_state_init(MachineState *machine)