virdomainjob: check if cb is not NULL before dereferencing

The callback struct does not always have to be set which could
cause a dereferencing of a NULL pointer. This patch adds check
against NULL in missing places before dereferencing.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Kristina Hanicova 2022-09-30 13:51:28 +02:00 committed by Ján Tomko
parent 3478cca80e
commit 39e98f4113
1 changed files with 2 additions and 2 deletions

View File

@ -626,7 +626,7 @@ virDomainObjEndJob(virDomainObj *obj)
virDomainObjResetJob(obj->job);
if (virDomainTrackJob(job) &&
if (virDomainTrackJob(job) && obj->job->cb &&
obj->job->cb->saveStatusPrivate)
obj->job->cb->saveStatusPrivate(obj);
/* We indeed need to wake up ALL threads waiting because
@ -662,7 +662,7 @@ virDomainObjEndAsyncJob(virDomainObj *obj)
obj, obj->def->name);
virDomainObjResetAsyncJob(obj->job);
if (obj->job->cb->saveStatusPrivate)
if (obj->job->cb && obj->job->cb->saveStatusPrivate)
obj->job->cb->saveStatusPrivate(obj);
virCondBroadcast(&obj->job->asyncCond);
}