]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/xen.git/commitdiff
libxlu: properly free buffer in PCI related functions
authorWei Liu <wei.liu2@citrix.com>
Tue, 28 Jul 2015 16:23:56 +0000 (17:23 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 29 Jul 2015 14:26:56 +0000 (15:26 +0100)
Free buffer in both success and failure paths.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxl/libxlu_pci.c

index 026413bc16615259c11a94e7e14cd3b97cbb8f85..2cd793d223f2f524593518e20c4cbb8880c3d043 100644 (file)
@@ -167,17 +167,18 @@ int xlu_pci_parse_bdf(XLU_Config *cfg, libxl_device_pci *pcidev, const char *str
         }
     }
 
-    free(buf2);
-
     if ( tok != ptr || state != STATE_TERMINAL )
         goto parse_error;
 
     /* Just a pretty way to fill in the values */
     pcidev_struct_fill(pcidev, dom, bus, dev, func, vslot << 3);
 
+    free(buf2);
+
     return 0;
 
 parse_error:
+    free(buf2);
     return ERROR_INVAL;
 }
 
@@ -246,14 +247,15 @@ int xlu_rdm_parse(XLU_Config *cfg, libxl_rdm_reserve *rdm, const char *str)
         }
     }
 
-    free(buf2);
-
     if (tok != ptr || state != STATE_TERMINAL)
         goto parse_error;
 
+    free(buf2);
+
     return 0;
 
 parse_error:
+    free(buf2);
     return ERROR_INVAL;
 }