mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-28 07:25:17 +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);
|
pciFreeDevice(conn, pci);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i != --vm->def->nhostdevs)
|
if (vm->def->nhostdevs > 1) {
|
||||||
memmove(&vm->def->hostdevs[i],
|
memmove(vm->def->hostdevs + i,
|
||||||
&vm->def->hostdevs[i+1],
|
vm->def->hostdevs + i + 1,
|
||||||
sizeof(*vm->def->hostdevs) * (vm->def->nhostdevs-i));
|
sizeof(*vm->def->hostdevs) *
|
||||||
|
(vm->def->nhostdevs - (i + 1)));
|
||||||
|
vm->def->nhostdevs--;
|
||||||
if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs) < 0) {
|
if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs) < 0) {
|
||||||
virReportOOMError(conn);
|
/* ignore, harmless */
|
||||||
ret = -1;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
VIR_FREE(vm->def->hostdevs);
|
||||||
|
vm->def->nhostdevs = 0;
|
||||||
|
}
|
||||||
|
virDomainHostdevDefFree(detach);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user