[PATCH 4/4] ch: Avoid memleak on disk detach in chDomainRemoveDevice()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Michal Privoznik <mprivozn@xxxxxxxxxx>

The aim of chDomainRemoveDevice() is to remove device from
virDomainDef. Well, in case of disks this is done by calling
virDomainDiskRemove() which merely just removes it from the array
of virDomainDiskDef-s but leaves it up to the caller to actually
free the disk def.

1,286 (560 direct, 726 indirect) bytes in 1 blocks are definitely lost in loss record 2,005 of 2,041
   at 0x4919EF3: calloc (vg_replace_malloc.c:1675)
   by 0x4FEB249: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.8400.3)
   by 0x4AFD9A4: virDomainDiskDefNewSource (domain_conf.c:2409)
   by 0x4B10ACA: virDomainDiskDefParseXML (domain_conf.c:8509)
   by 0x4B24F07: virDomainDeviceDefParse (domain_conf.c:14631)
   by 0xB8D8881: chDomainAttachDeviceLiveAndUpdateConfig (ch_hotplug.c:135)
   by 0xB8CCFE0: chDomainAttachDeviceFlags (ch_driver.c:2376)
   by 0xB8CD057: chDomainAttachDevice (ch_driver.c:2394)
   by 0x4DC1C7D: virDomainAttachDevice (libvirt-domain.c:8951)
   by 0x405E545: remoteDispatchDomainAttachDevice (remote_daemon_dispatch_stubs.h:3763)
   by 0x405E495: remoteDispatchDomainAttachDeviceHelper (remote_daemon_dispatch_stubs.h:3742)
   by 0x4BF3164: virNetServerProgramDispatchCall (virnetserverprogram.c:423)

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/ch/ch_hotplug.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/ch/ch_hotplug.c b/src/ch/ch_hotplug.c
index cfa11cc5e5..0a55a57069 100644
--- a/src/ch/ch_hotplug.c
+++ b/src/ch/ch_hotplug.c
@@ -212,6 +212,7 @@ chDomainRemoveDevice(virDomainObj *vm,
         for (i = 0; i < vm->def->ndisks; i++) {
             if (vm->def->disks[i] == device->data.disk) {
                 virDomainDiskRemove(vm->def, i);
+                g_clear_pointer(&device->data.disk, virDomainDiskDefFree);
                 break;
             }
         }
-- 
2.49.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux