diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c index 0dae8d9ed5..b4ec5794cc 100644 --- a/src/xen/xen_hypervisor.c +++ b/src/xen/xen_hypervisor.c @@ -2732,7 +2732,7 @@ xenHypervisorMakeCapabilities(virConnectPtr conn) #ifdef __sun return xenHypervisorMakeCapabilitiesSunOS(conn); #else - virCapsPtr caps; + virCapsPtr caps = NULL; FILE *cpuinfo, *capabilities; struct utsname utsname; @@ -2765,11 +2765,12 @@ xenHypervisorMakeCapabilities(virConnectPtr conn) cpuinfo, capabilities); if (caps == NULL) - return NULL; + goto cleanup; if (virNodeSuspendGetTargetMask(&caps->host.powerMgmt) < 0) VIR_WARN("Failed to get host power management capabilities"); +cleanup: VIR_FORCE_FCLOSE(cpuinfo); VIR_FORCE_FCLOSE(capabilities); diff --git a/src/xen/xen_inotify.c b/src/xen/xen_inotify.c index d0cd90709a..f7495b5d34 100644 --- a/src/xen/xen_inotify.c +++ b/src/xen/xen_inotify.c @@ -123,6 +123,7 @@ xenInotifyXendDomainsDirLookup(virConnectPtr conn, const char *filename, if (!(*name = strdup(dom->name))) { virReportOOMError(); + virDomainFree(dom); return -1; } memcpy(uuid, dom->uuid, VIR_UUID_BUFLEN);