Skip to content

Commit

Permalink
microvm: fix memory leak in microvm_fix_kernel_cmdline
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
slp authored and bonzini committed Nov 19, 2019
1 parent b73f059 commit c3157b7
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions hw/i386/microvm.c
Expand Up @@ -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)
Expand Down

0 comments on commit c3157b7

Please sign in to comment.