]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fix double free of hostdev on OOM in xenParseSxprPCI
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 25 Sep 2013 09:20:45 +0000 (10:20 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 25 Sep 2013 17:12:08 +0000 (18:12 +0100)
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 <berrange@redhat.com>
src/xenxs/xen_sxpr.c

index bb8a335cf53dd30b51f3ddf9985643d49441f8b9..3cbe958b643f6611abe271c50d0f97bb9c0e370e 100644 (file)
@@ -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;
     }