]> xenbits.xensource.com Git - qemu-xen-3.4-testing.git/commitdiff
hw/pass-through.c: fix a leak on error in pt_init()
authorIan Jackson <ian.jackson@eu.citrix.com>
Tue, 24 Feb 2009 12:32:01 +0000 (12:32 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 24 Feb 2009 12:32:01 +0000 (12:32 +0000)
vslots needs to be freed on error

Signed-off-by: Simon Horman <horms@verge.net.au>
hw/pass-through.c

index f29e783a9eecfe56f871bef012d18126b60b3293..96e7160a5334129e125c337834fa50c0590f0e06 100644 (file)
@@ -3770,7 +3770,7 @@ int power_off_php_slot(int php_slot)
 
 int pt_init(PCIBus *e_bus, const char *direct_pci)
 {
-    int seg, b, d, f, php_slot = 0;
+    int seg, b, d, f, php_slot = 0, status = -1;
     struct pt_dev *pt_dev;
     struct pci_access *pci_access;
     char *vslots;
@@ -3814,8 +3814,7 @@ int pt_init(PCIBus *e_bus, const char *direct_pci)
         if ( pt_dev == NULL )
         {
             PT_LOG("Error: Registration failed (%02x:%02x.%x)\n", b, d, f);
-            free(direct_pci_head);
-            return -1;
+            goto err;
         }
 
         /* Record the virtual slot info */
@@ -3834,10 +3833,11 @@ int pt_init(PCIBus *e_bus, const char *direct_pci)
     /* Write virtual slots info to xenstore for Control panel use */
     xenstore_write_vslots(vslots);
 
+    status = 0;
+err:
     qemu_free(vslots);
     free(direct_pci_head);
 
-    /* Success */
-    return 0;
+    return status;
 }