mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-14 08:35:15 +00:00
Fix leak in PCI hostdev hot-unplug
* src/qemu_driver.c: sync the hostdev hot-unplug code with the disk/net code.
This commit is contained in:
parent
8881ae1bf8
commit
a70da51ff7
@ -6206,14 +6206,20 @@ static int qemudDomainDetachHostPciDevice(virConnectPtr conn,
|
||||
pciFreeDevice(conn, pci);
|
||||
}
|
||||
|
||||
if (i != --vm->def->nhostdevs)
|
||||
memmove(&vm->def->hostdevs[i],
|
||||
&vm->def->hostdevs[i+1],
|
||||
sizeof(*vm->def->hostdevs) * (vm->def->nhostdevs-i));
|
||||
if (vm->def->nhostdevs > 1) {
|
||||
memmove(vm->def->hostdevs + i,
|
||||
vm->def->hostdevs + i + 1,
|
||||
sizeof(*vm->def->hostdevs) *
|
||||
(vm->def->nhostdevs - (i + 1)));
|
||||
vm->def->nhostdevs--;
|
||||
if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs) < 0) {
|
||||
virReportOOMError(conn);
|
||||
ret = -1;
|
||||
/* ignore, harmless */
|
||||
}
|
||||
} else {
|
||||
VIR_FREE(vm->def->hostdevs);
|
||||
vm->def->nhostdevs = 0;
|
||||
}
|
||||
virDomainHostdevDefFree(detach);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user