Skip to contentSkip to conversation

tools: fix inspired by Coverity scan

PATCH New Wei Liu 2 participants 3 messages Jul 28, 2015 – Jul 29, 2015

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH v3 1/1 tools: fix inspired by Coverity scan

Wei Liu (1):
libxlu: properly free buffer in PCI related functions

 tools/libxl/libxlu_pci.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
Signature · 1 line
2.1.4
author
#1 lore raw

PATCH v3 1/1 libxlu: properly free buffer in PCI related functions

Free buffer in both success and failure paths.

---
 tools/libxl/libxlu_pci.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
tools/libxl/libxlu_pci.c +6 -4
index 026413b..2cd793d 100644
@@ -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;
 }
 
Signature · 1 line
2.1.4
#2 lore raw

Re: [PATCH for-4.6 v3] libxlu: properly free buffer in PCI related functions

Quoted 3 lines · Wei Liu

Free buffer in both success and failure paths.

Acked + applied.

Quoted 49 lines
---
 tools/libxl/libxlu_pci.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
tools/libxl/libxlu_pci.c +0 -0
index 026413b..2cd793d 100644
@@ -167,17 +167,18 @@ int xlu_pci_parse_bdf(XLU_Config *cfg, 

libxl_device_pci *pcidev, const char *str

         }
     }
tools/libxl/libxlu_pci.c +6 -4
-    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;
 }