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 <jtomko@redhat.com>
Fixes: aca37c3fb2
This commit is contained in:
Ján Tomko 2020-09-14 13:29:23 +02:00
parent a3c340e05f
commit af16e754cd
3 changed files with 7 additions and 1 deletions

View 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);

View 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,

View 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;