]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuProcessReconnect: clear 'oldjob'
authorJán Tomko <jtomko@redhat.com>
Mon, 14 Sep 2020 11:29:23 +0000 (13:29 +0200)
committerJán Tomko <jtomko@redhat.com>
Mon, 14 Sep 2020 16:10:56 +0000 (18:10 +0200)
After we started copying the privateData pointer in
qemuDomainObjRestoreJob, we should also free them
once we're done with them.

Register the clear function and use g_auto.
Also add a check for job->cb to qemuDomainObjClearJob,
to prevent freeing an uninitialized job.

https://bugzilla.redhat.com/show_bug.cgi?id=1878450

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: aca37c3fb2e8d733c2788ca4b796c153ea7ce391
src/qemu/qemu_domainjob.c
src/qemu/qemu_domainjob.h
src/qemu/qemu_process.c

index e5910a11a109945a90e7a6f7ce968d4a75ba42a6..3c2c6b9179d6eeace5314b18a4ebc310df21ce69 100644 (file)
@@ -248,6 +248,9 @@ qemuDomainObjRestoreJob(virDomainObjPtr obj,
 void
 qemuDomainObjClearJob(qemuDomainJobObjPtr job)
 {
+    if (!job->cb)
+        return;
+
     qemuDomainObjResetJob(job);
     qemuDomainObjResetAsyncJob(job);
     g_clear_pointer(&job->privateData, job->cb->freeJobPrivate);
index eedd84c503b8888e36ed05f369eff60aa967f00c..79f012725254302cd29cd3f196a9858540e6987c 100644 (file)
@@ -275,6 +275,7 @@ int qemuDomainJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
 bool qemuDomainTrackJob(qemuDomainJob job);
 
 void qemuDomainObjClearJob(qemuDomainJobObjPtr job);
+G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(qemuDomainJobObj, qemuDomainObjClearJob);
 
 int
 qemuDomainObjInitJob(qemuDomainJobObjPtr job,
index b1af35b933f1e378771d647c4529e392793273c0..073b2d96e039313920f535b56a5814f18ce335f0 100644 (file)
@@ -8081,7 +8081,9 @@ qemuProcessReconnect(void *opaque)
     virQEMUDriverPtr driver = data->driver;
     virDomainObjPtr obj = data->obj;
     qemuDomainObjPrivatePtr priv;
-    qemuDomainJobObj oldjob;
+    g_auto(qemuDomainJobObj) oldjob = {
+      .cb = NULL,
+    };
     int state;
     int reason;
     g_autoptr(virQEMUDriverConfig) cfg = NULL;