diff options
Diffstat (limited to 'libraries/libvirt/patches/0002-blockjob-avoid-memory-leak-during-block-pivot.patch')
-rw-r--r-- | libraries/libvirt/patches/0002-blockjob-avoid-memory-leak-during-block-pivot.patch | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/libraries/libvirt/patches/0002-blockjob-avoid-memory-leak-during-block-pivot.patch b/libraries/libvirt/patches/0002-blockjob-avoid-memory-leak-during-block-pivot.patch new file mode 100644 index 0000000000..1f430369ff --- /dev/null +++ b/libraries/libvirt/patches/0002-blockjob-avoid-memory-leak-during-block-pivot.patch @@ -0,0 +1,48 @@ +From 7620b422e515249bbfff02d0372301334fe1dd50 Mon Sep 17 00:00:00 2001 +From: Eric Blake <eblake@redhat.com> +Date: Wed, 6 Aug 2014 14:48:59 -0600 +Subject: [PATCH 2/3] blockjob: avoid memory leak during block pivot + +Valgrind caught a memory leak: + +==2018== 9 bytes in 1 blocks are definitely lost in loss record 143 of 927 +==2018== at 0x4A0645D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) +==2018== by 0x8C42369: strdup (strdup.c:42) +==2018== by 0x50EACC9: virStrdup (virstring.c:676) +==2018== by 0x50E79E5: virStorageSourceCopy (virstoragefile.c:1845) +==2018== by 0x20A3FAA7: qemuDomainBlockCommit (qemu_driver.c:15620) +==2018== by 0x51DC6B2: virDomainBlockCommit (libvirt.c:20092) + +I traced it to the fact that blockcopy and blockcommit end up +reparsing a backing chain on pivot, but the chain parsing code +doesn't gracefully handle the case where the backing file is +already known. + +I'm not exactly sure when this was introduced, but suspect that the +refactoring in commit 9944b71 and friends that moved towards probing +in-place rather than into a temporary structure are part of the cause. + +* src/util/virstoragefile.c (virStorageFileGetMetadataInternal): +Don't leak any prior value. + +Signed-off-by: Eric Blake <eblake@redhat.com> +(cherry picked from commit a595a005725f142e1a258d10f7647982efa3cfd8) +--- + src/util/virstoragefile.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c +index 3da9073..5b6b2f5 100644 +--- a/src/util/virstoragefile.c ++++ b/src/util/virstoragefile.c +@@ -817,6 +817,7 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta, + goto cleanup; + } + ++ VIR_FREE(meta->backingStoreRaw); + if (fileTypeInfo[meta->format].getBackingStore != NULL) { + int store = fileTypeInfo[meta->format].getBackingStore(&meta->backingStoreRaw, + backingFormat, +-- +2.0.3 + |