diff options
author | Sergio Lopez <slp@redhat.com> | 2019-11-12 17:34:23 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2019-11-19 10:00:36 +0100 |
commit | c3157b74c47f886f99df752500f7cf76e7a287dd (patch) | |
tree | ca4fd82bc879a945a135199f2c36b802317e9491 | |
parent | b73f059cf2dce327f4f5936a1e6d4d7b898c6a71 (diff) |
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.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index 8aacd6c8d1..def37e60f7 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) |