[PATCH] virdomainjob: check if cb is not NULL before dereferencing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 src/conf/virdomainjob.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/conf/virdomainjob.c b/src/conf/virdomainjob.c
index 0c67e84ef1..ca0215bc23 100644
--- a/src/conf/virdomainjob.c
+++ b/src/conf/virdomainjob.c
@@ -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);
 }
-- 
2.37.3




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux