From e5c10018c5917d07ee23579ad5a8de3e2818d030 Mon Sep 17 00:00:00 2001 From: Kristina Hanicova Date: Wed, 16 Mar 2022 15:08:39 +0100 Subject: [PATCH] qemu: domainjob: Allow InitJob if cb is not set in qemuDomainObjInitJob() This allows init job even if cb structure is not set. This patch also includes slight rewriting of the function to make it look cleaner when freeing resources, by allocating privateData at the end. Signed-off-by: Kristina Hanicova Reviewed-by: Michal Privoznik --- src/qemu/qemu_domainjob.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_domainjob.c b/src/qemu/qemu_domainjob.c index 7b81cd8a2b..28c09ae179 100644 --- a/src/qemu/qemu_domainjob.c +++ b/src/qemu/qemu_domainjob.c @@ -189,17 +189,18 @@ qemuDomainObjInitJob(qemuDomainJobObj *job, memset(job, 0, sizeof(*job)); job->cb = cb; - if (!(job->privateData = job->cb->allocJobPrivate())) + if (virCondInit(&job->cond) < 0) return -1; - if (virCondInit(&job->cond) < 0) { - job->cb->freeJobPrivate(job->privateData); + if (virCondInit(&job->asyncCond) < 0) { + virCondDestroy(&job->cond); return -1; } - if (virCondInit(&job->asyncCond) < 0) { - job->cb->freeJobPrivate(job->privateData); + if (job->cb && + !(job->privateData = job->cb->allocJobPrivate())) { virCondDestroy(&job->cond); + virCondDestroy(&job->asyncCond); return -1; }