From f937ef18118e499e5049bca012bed51ccc5d2b3e Mon Sep 17 00:00:00 2001
Message-Id: <f937ef18118e499e5049bca012bed51ccc5d2b3e.1380703761.git.jdenemar@redhat.com>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 27 Sep 2013 16:02:39 +0200
Subject: [PATCH] qemu: Don't leak reference to virQEMUDriverConfigPtr
https://bugzilla.redhat.com/show_bug.cgi?id=1011330 (case D)
qemuProcessStart created two references to virQEMUDriverConfigPtr before
calling fork():
cfg = virQEMUDriverGetConfig(driver);
...
hookData.cfg = virObjectRef(cfg);
However, the child only unreferenced hookData.cfg and the parent only
removed the cfg reference. That said, we don't need to increment the
reference counter when assigning cfg to hookData. Both the child and the
parent will correctly remove the reference on cfg (the child will do
that through hookData).
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
(cherry picked from commit 833cdab6d2ad7521c954948adf3c7d3c3b42ae9f)
---
src/qemu/qemu_process.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 843ff76..1bd0d04 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3475,7 +3475,8 @@ int qemuProcessStart(virConnectPtr conn,
hookData.conn = conn;
hookData.vm = vm;
hookData.driver = driver;
- hookData.cfg = virObjectRef(cfg);
+ /* We don't increase cfg's reference counter here. */
+ hookData.cfg = cfg;
VIR_DEBUG("Beginning VM startup process");
--
1.8.3.2