提交 a70da51f 编写于 作者: M Mark McLoughlin

Fix leak in PCI hostdev hot-unplug

* src/qemu_driver.c: sync the hostdev hot-unplug code with the disk/net
  code.
上级 8881ae1b
......@@ -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 (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs) < 0) {
virReportOOMError(conn);
ret = -1;
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) {
/* ignore, harmless */
}
} else {
VIR_FREE(vm->def->hostdevs);
vm->def->nhostdevs = 0;
}
virDomainHostdevDefFree(detach);
return ret;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册