]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuhotplugtest: Free monitor iff successfully initialized
authorMichal Privoznik <mprivozn@redhat.com>
Sat, 27 Jun 2020 07:20:21 +0000 (09:20 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 29 Jun 2020 10:38:22 +0000 (12:38 +0200)
If initializing test monitor in testQemuHotplugCpuPrepare()
fails, the control jumps to error label where
testQemuHotplugCpuDataFree() is called. But since the data->mon
is NULL due to aforementioned failure,
qemuMonitorTestGetMonitor() dereferences a NULL pointer leading
to a SIGSEGV.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
tests/qemuhotplugtest.c

index ba3fc4d8148a231ab40320bea8a2a08e316d9dcc..ba30cf5aa6ef5d423d97747c2576f570d2783754 100644 (file)
@@ -399,9 +399,11 @@ testQemuHotplugCpuDataFree(struct testQemuHotplugCpuData *data)
         virObjectUnref(data->vm);
     }
 
-    mon = qemuMonitorTestGetMonitor(data->mon);
-    virObjectLock(mon);
-    qemuMonitorTestFree(data->mon);
+    if (data->mon) {
+        mon = qemuMonitorTestGetMonitor(data->mon);
+        virObjectLock(mon);
+        qemuMonitorTestFree(data->mon);
+    }
     VIR_FREE(data);
 }