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 <khanicov@xxxxxxxxxx> --- 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; } -- 2.35.1