From: Michal Privoznik Date: Sat, 27 Jun 2020 07:20:21 +0000 (+0200) Subject: qemuhotplugtest: Free monitor iff successfully initialized X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=b150fbc4fe97b823707b7433dfb37e4f2f5b685e;p=libvirt.git qemuhotplugtest: Free monitor iff successfully initialized 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 Reviewed-by: Andrea Bolognani --- diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index ba3fc4d814..ba30cf5aa6 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -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); }