[libvirt] [PATCH 1/2] Fix net/disk hot-unplug segfault

When we hot-unplug the last device, we're currently double-freeing the device definition. Reported by Michal Nowak here: https://bugzilla.redhat.com/523953 * src/qemu_driver.c: fix double free --- src/qemu_driver.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qemu_driver.c b/src/qemu_driver.c index a65334f..de31581 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -5998,7 +5998,7 @@ try_command: /* ignore, harmless */ } } else { - VIR_FREE(vm->def->disks[0]); + VIR_FREE(vm->def->disks); vm->def->ndisks = 0; } virDomainDiskDefFree(detach); @@ -6100,7 +6100,7 @@ qemudDomainDetachNetDevice(virConnectPtr conn, /* ignore, harmless */ } } else { - VIR_FREE(vm->def->nets[0]); + VIR_FREE(vm->def->nets); vm->def->nnets = 0; } virDomainNetDefFree(detach); -- 1.6.2.5

On Thu, 2009-09-17 at 16:02 +0100, Mark McLoughlin wrote:
When we hot-unplug the last device, we're currently double-freeing the device definition.
Reported by Michal Nowak here:
Sorry, I got bugs mixed up, it was Martin Banas who reported this. Cheers, Mark.
* src/qemu_driver.c: fix double free --- src/qemu_driver.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/qemu_driver.c b/src/qemu_driver.c index a65334f..de31581 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -5998,7 +5998,7 @@ try_command: /* ignore, harmless */ } } else { - VIR_FREE(vm->def->disks[0]); + VIR_FREE(vm->def->disks); vm->def->ndisks = 0; } virDomainDiskDefFree(detach); @@ -6100,7 +6100,7 @@ qemudDomainDetachNetDevice(virConnectPtr conn, /* ignore, harmless */ } } else { - VIR_FREE(vm->def->nets[0]); + VIR_FREE(vm->def->nets); vm->def->nnets = 0; } virDomainNetDefFree(detach);

On Thu, Sep 17, 2009 at 04:02:10PM +0100, Mark McLoughlin wrote:
When we hot-unplug the last device, we're currently double-freeing the device definition.
Reported by Michal Nowak here:
https://bugzilla.redhat.com/523953
* src/qemu_driver.c: fix double free --- src/qemu_driver.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/qemu_driver.c b/src/qemu_driver.c index a65334f..de31581 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -5998,7 +5998,7 @@ try_command: /* ignore, harmless */ } } else { - VIR_FREE(vm->def->disks[0]); + VIR_FREE(vm->def->disks); vm->def->ndisks = 0; } virDomainDiskDefFree(detach); @@ -6100,7 +6100,7 @@ qemudDomainDetachNetDevice(virConnectPtr conn, /* ignore, harmless */ } } else { - VIR_FREE(vm->def->nets[0]); + VIR_FREE(vm->def->nets); vm->def->nnets = 0; } virDomainNetDefFree(detach);
ACk Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
participants (2)
-
Daniel P. Berrange
-
Mark McLoughlin