From: Daniel P. Berrange Date: Wed, 25 Sep 2013 09:20:45 +0000 (+0100) Subject: Fix double free of hostdev on OOM in xenParseSxprPCI X-Git-Tag: v1.1.3-rc1~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0dff76c2d3aea654420dd807d0cb5c7a90089325;p=thirdparty%2Flibvirt.git Fix double free of hostdev on OOM in xenParseSxprPCI If xenParseSxprPCI failed to expand the def->hostdevs array due to OOM, it would free the hostdev instance twice. Signed-off-by: Daniel P. Berrange --- diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c index bb8a335cf5..3cbe958b64 100644 --- a/src/xenxs/xen_sxpr.c +++ b/src/xenxs/xen_sxpr.c @@ -1055,10 +1055,8 @@ xenParseSxprPCI(virDomainDefPtr def, dev->source.subsys.u.pci.addr.slot = slotID; dev->source.subsys.u.pci.addr.function = funcID; - if (VIR_REALLOC_N(def->hostdevs, def->nhostdevs+1) < 0) { - virDomainHostdevDefFree(dev); + if (VIR_REALLOC_N(def->hostdevs, def->nhostdevs+1) < 0) goto error; - } def->hostdevs[def->nhostdevs++] = dev; }