From bfaac4c2b11e0070d19570ad0f4273a93ed5dbec Mon Sep 17 00:00:00 2001 From: William Douglas Date: Fri, 1 Oct 2021 11:12:34 -0700 Subject: [PATCH] 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 --- src/ch/ch_monitor.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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; }