From: Ján Tomko Date: Mon, 14 Sep 2020 11:29:23 +0000 (+0200) Subject: qemuProcessReconnect: clear 'oldjob' X-Git-Tag: v6.8.0-rc1~146 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af16e754cd4efc3ca1df2b2e725945be743e87f9;p=thirdparty%2Flibvirt.git qemuProcessReconnect: clear 'oldjob' 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 Fixes: aca37c3fb2e8d733c2788ca4b796c153ea7ce391 --- diff --git a/src/qemu/qemu_domainjob.c b/src/qemu/qemu_domainjob.c index e5910a11a1..3c2c6b9179 100644 --- a/src/qemu/qemu_domainjob.c +++ b/src/qemu/qemu_domainjob.c @@ -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); diff --git a/src/qemu/qemu_domainjob.h b/src/qemu/qemu_domainjob.h index eedd84c503..79f0127252 100644 --- a/src/qemu/qemu_domainjob.h +++ b/src/qemu/qemu_domainjob.h @@ -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, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index b1af35b933..073b2d96e0 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -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;