From: Martin Kletzander Date: Tue, 19 Jun 2012 10:08:49 +0000 (+0200) Subject: domain_conf: fix possible memory leak X-Git-Tag: v0.9.13-rc1~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=830d035ff5a88c3896a6e508364e34697de941a1;p=thirdparty%2Flibvirt.git domain_conf: fix possible memory leak Until now, it was possible to crash libvirtd when defining domain with channel device with missing source element. When creating new virDomainChrDef, target.port is set to -1, but unfortunately it is an union with addresses that virDomainChrDefFree tries to free in case the deviceType is channel. Having the port set to -1 is intended, however the cleanest way to get around the problems with the crash seems to be renumbering the VIR_DOMAIN_CHR_CHANNEL_ target types to cover new NONE type (with value 0) being the default (no target type yet). --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5ea264f715..ef6077ee28 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -307,6 +307,7 @@ VIR_ENUM_IMPL(virDomainNetInterfaceLinkState, VIR_DOMAIN_NET_INTERFACE_LINK_STAT VIR_ENUM_IMPL(virDomainChrChannelTarget, VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST, + "none", "guestfwd", "virtio") diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 86c1e63093..44280bae8e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -855,7 +855,8 @@ enum virDomainChrDeviceType { }; enum virDomainChrChannelTargetType { - VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD = 0, + VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_NONE = 0, + VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD, VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO, VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST,