From: William Douglas Date: Fri, 1 Oct 2021 18:12:34 +0000 (-0700) Subject: ch: Correctly ref and close the virCHMonitor in virCHMonitorNew X-Git-Tag: v7.9.0-rc1~275 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bfaac4c2b11e0070d19570ad0f4273a93ed5dbec;p=thirdparty%2Flibvirt.git ch: Correctly ref and close the virCHMonitor in virCHMonitorNew In virCHMontiorNew the monitor object was referenced an additional time incorrectly preventing it from being disposed of, and wasn't always closed properly on failure. Signed-off-by: William Douglas Reviewed-by: Laine Stump --- diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c index a1430f0e65..807989579b 100644 --- a/src/ch/ch_monitor.c +++ b/src/ch/ch_monitor.c @@ -468,7 +468,7 @@ virCHMonitorNew(virDomainObj *vm, const char *socketdir) if (!vm->def) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("VM is not defined")); - return NULL; + goto cleanup; } /* prepare to launch Cloud-Hypervisor socket */ @@ -502,12 +502,13 @@ virCHMonitorNew(virDomainObj *vm, const char *socketdir) mon->handle = curl_easy_init(); /* now has its own reference */ - virObjectRef(mon); mon->vm = virObjectRef(vm); ret = mon; + mon = NULL; cleanup: + virCHMonitorClose(mon); virCommandFree(cmd); return ret; }