]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
microvm: fix memory leak in microvm_fix_kernel_cmdline
authorSergio Lopez <slp@redhat.com>
Tue, 12 Nov 2019 16:34:23 +0000 (17:34 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 19 Nov 2019 09:00:36 +0000 (10:00 +0100)
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>
hw/i386/microvm.c

index 8aacd6c8d127169b4db89aaa37a29173efa37476..def37e60f79443ebe6df2d11a90674e3cbcc0006 100644 (file)
@@ -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)