提交 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, ...@@ -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) *
if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs) < 0) { (vm->def->nhostdevs - (i + 1)));
virReportOOMError(conn); vm->def->nhostdevs--;
ret = -1; 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; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册