[libvirt] [PATCH 5/5] xenFoxenFormatXLDisk: Don't leak @target

Michal Privoznik posted 5 patches 9 years ago
[libvirt] [PATCH 5/5] xenFoxenFormatXLDisk: Don't leak @target
Posted by Michal Privoznik 9 years ago
==11260== 1,006 bytes in 1 blocks are definitely lost in loss record 106 of 111
==11260==    at 0x4C2AE5F: malloc (vg_replace_malloc.c:297)
==11260==    by 0x4C2BDFF: realloc (vg_replace_malloc.c:693)
==11260==    by 0x4EA430B: virReallocN (viralloc.c:245)
==11260==    by 0x4EA7C52: virBufferGrow (virbuffer.c:130)
==11260==    by 0x4EA7D28: virBufferAdd (virbuffer.c:165)
==11260==    by 0x4EA8E10: virBufferStrcat (virbuffer.c:718)
==11260==    by 0x42D263: xenFormatXLDiskSrcNet (xen_xl.c:960)
==11260==    by 0x42D4EB: xenFormatXLDiskSrc (xen_xl.c:1015)
==11260==    by 0x42D870: xenFormatXLDisk (xen_xl.c:1101)
==11260==    by 0x42DA89: xenFormatXLDomainDisks (xen_xl.c:1148)
==11260==    by 0x42EAF8: xenFormatXL (xen_xl.c:1558)
==11260==    by 0x40E85F: testCompareParseXML (xlconfigtest.c:105)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/xenconfig/xen_xl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c
index 18d9fe369..2c9174e53 100644
--- a/src/xenconfig/xen_xl.c
+++ b/src/xenconfig/xen_xl.c
@@ -1034,6 +1034,7 @@ xenFormatXLDisk(virConfValuePtr list, virDomainDiskDefPtr disk)
     int format = virDomainDiskGetFormat(disk);
     const char *driver = virDomainDiskGetDriver(disk);
     char *target = NULL;
+    int ret = -1;
 
     /* format */
     virBufferAddLit(&buf, "format=");
@@ -1119,12 +1120,12 @@ xenFormatXLDisk(virConfValuePtr list, virDomainDiskDefPtr disk)
         tmp->next = val;
     else
         list->list = val;
-    return 0;
+    ret = 0;
 
  cleanup:
     VIR_FREE(target);
     virBufferFreeAndReset(&buf);
-    return -1;
+    return ret;
 }
 
 
-- 
2.11.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 5/5] xenFoxenFormatXLDisk: Don't leak @target
Posted by Jim Fehlig 9 years ago
Michal Privoznik wrote:
> ==11260== 1,006 bytes in 1 blocks are definitely lost in loss record 106 of 111
> ==11260==    at 0x4C2AE5F: malloc (vg_replace_malloc.c:297)
> ==11260==    by 0x4C2BDFF: realloc (vg_replace_malloc.c:693)
> ==11260==    by 0x4EA430B: virReallocN (viralloc.c:245)
> ==11260==    by 0x4EA7C52: virBufferGrow (virbuffer.c:130)
> ==11260==    by 0x4EA7D28: virBufferAdd (virbuffer.c:165)
> ==11260==    by 0x4EA8E10: virBufferStrcat (virbuffer.c:718)
> ==11260==    by 0x42D263: xenFormatXLDiskSrcNet (xen_xl.c:960)
> ==11260==    by 0x42D4EB: xenFormatXLDiskSrc (xen_xl.c:1015)
> ==11260==    by 0x42D870: xenFormatXLDisk (xen_xl.c:1101)
> ==11260==    by 0x42DA89: xenFormatXLDomainDisks (xen_xl.c:1148)
> ==11260==    by 0x42EAF8: xenFormatXL (xen_xl.c:1558)
> ==11260==    by 0x40E85F: testCompareParseXML (xlconfigtest.c:105)
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

Strange function name in $subject. s/xenFoxenFormatXLDisk/xenFormatXLDisk/

ACK.

Regards,
Jim

> ---
>  src/xenconfig/xen_xl.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c
> index 18d9fe369..2c9174e53 100644
> --- a/src/xenconfig/xen_xl.c
> +++ b/src/xenconfig/xen_xl.c
> @@ -1034,6 +1034,7 @@ xenFormatXLDisk(virConfValuePtr list, virDomainDiskDefPtr disk)
>      int format = virDomainDiskGetFormat(disk);
>      const char *driver = virDomainDiskGetDriver(disk);
>      char *target = NULL;
> +    int ret = -1;
>  
>      /* format */
>      virBufferAddLit(&buf, "format=");
> @@ -1119,12 +1120,12 @@ xenFormatXLDisk(virConfValuePtr list, virDomainDiskDefPtr disk)
>          tmp->next = val;
>      else
>          list->list = val;
> -    return 0;
> +    ret = 0;
>  
>   cleanup:
>      VIR_FREE(target);
>      virBufferFreeAndReset(&buf);
> -    return -1;
> +    return ret;
>  }
>  
>  

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 5/5] xenFoxenFormatXLDisk: Don't leak @target
Posted by Michal Privoznik 9 years ago
On 02/06/2017 08:18 PM, Jim Fehlig wrote:
> Michal Privoznik wrote:
>> ==11260== 1,006 bytes in 1 blocks are definitely lost in loss record 106 of 111
>> ==11260==    at 0x4C2AE5F: malloc (vg_replace_malloc.c:297)
>> ==11260==    by 0x4C2BDFF: realloc (vg_replace_malloc.c:693)
>> ==11260==    by 0x4EA430B: virReallocN (viralloc.c:245)
>> ==11260==    by 0x4EA7C52: virBufferGrow (virbuffer.c:130)
>> ==11260==    by 0x4EA7D28: virBufferAdd (virbuffer.c:165)
>> ==11260==    by 0x4EA8E10: virBufferStrcat (virbuffer.c:718)
>> ==11260==    by 0x42D263: xenFormatXLDiskSrcNet (xen_xl.c:960)
>> ==11260==    by 0x42D4EB: xenFormatXLDiskSrc (xen_xl.c:1015)
>> ==11260==    by 0x42D870: xenFormatXLDisk (xen_xl.c:1101)
>> ==11260==    by 0x42DA89: xenFormatXLDomainDisks (xen_xl.c:1148)
>> ==11260==    by 0x42EAF8: xenFormatXL (xen_xl.c:1558)
>> ==11260==    by 0x40E85F: testCompareParseXML (xlconfigtest.c:105)
>>
>> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> 
> Strange function name in $subject. s/xenFoxenFormatXLDisk/xenFormatXLDisk/

Ah, indeed. I've started writing the function name and then copy-pasted
it. I am a giddy goat :-)

> 
> ACK.

Thanks, I've pushed this one.

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list