mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 07:17:44 +00:00
qemu: fix segfault when detaching non-existent network device
In qemuDomainDetachNetDevice, detach was being used before it had been
validated. If no matching device was found, this resulted in a
dereference of a NULL pointer.
This behavior was a regression introduced in commit
cf90342be0
, so it has not been a part of
any official libvirt release.
This commit is contained in:
parent
041109afef
commit
19c7980ee6
@ -2081,13 +2081,6 @@ qemuDomainDetachNetDevice(struct qemud_driver *driver,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virDomainNetGetActualType(detach) == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
|
|
||||||
ret = qemuDomainDetachThisHostDevice(driver, vm,
|
|
||||||
virDomainNetGetActualHostdev(detach),
|
|
||||||
-1);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!detach) {
|
if (!detach) {
|
||||||
qemuReportError(VIR_ERR_OPERATION_FAILED,
|
qemuReportError(VIR_ERR_OPERATION_FAILED,
|
||||||
_("network device %02x:%02x:%02x:%02x:%02x:%02x not found"),
|
_("network device %02x:%02x:%02x:%02x:%02x:%02x not found"),
|
||||||
@ -2097,6 +2090,13 @@ qemuDomainDetachNetDevice(struct qemud_driver *driver,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (virDomainNetGetActualType(detach) == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
|
||||||
|
ret = qemuDomainDetachThisHostDevice(driver, vm,
|
||||||
|
virDomainNetGetActualHostdev(detach),
|
||||||
|
-1);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if (!virDomainDeviceAddressIsValid(&detach->info,
|
if (!virDomainDeviceAddressIsValid(&detach->info,
|
||||||
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)) {
|
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)) {
|
||||||
qemuReportError(VIR_ERR_OPERATION_FAILED,
|
qemuReportError(VIR_ERR_OPERATION_FAILED,
|
||||||
|
Loading…
Reference in New Issue
Block a user