* [PATCH] microvm: fix memory leak in microvm_fix_kernel_cmdline
@ 2019-11-12 16:34 Sergio Lopez
2019-11-12 17:59 ` Paolo Bonzini
0 siblings, 1 reply; 2+ messages in thread
From: Sergio Lopez @ 2019-11-12 16:34 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Eduardo Habkost, Sergio Lopez, Michael S. Tsirkin,
Paolo Bonzini, Richard Henderson
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>
---
hw/i386/microvm.c | 2 ++
1 file changed, 2 insertions(+)
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)
--
2.23.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] microvm: fix memory leak in microvm_fix_kernel_cmdline
2019-11-12 16:34 [PATCH] microvm: fix memory leak in microvm_fix_kernel_cmdline Sergio Lopez
@ 2019-11-12 17:59 ` Paolo Bonzini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2019-11-12 17:59 UTC (permalink / raw)
To: Sergio Lopez, qemu-devel
Cc: Peter Maydell, Richard Henderson, Eduardo Habkost, Michael S. Tsirkin
On 12/11/19 17:34, Sergio Lopez wrote:
> 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>
> ---
> hw/i386/microvm.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> 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)
>
Queued, thanks.
Paolo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-11-12 18:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-12 16:34 [PATCH] microvm: fix memory leak in microvm_fix_kernel_cmdline Sergio Lopez
2019-11-12 17:59 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).