mirror of https://gitee.com/openkylin/libvirt.git
libxl_driver.c: validate 'driverName' earlier in libxlNodeDeviceDetachFlags()
The validation of 'driverName' does not depend on any other state and can be done right on the start of the function. We can fail earlier while avoiding a cleanup jump. Reviewed-by: Ján Tomko <jtomko@redhat.com> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
fc71d91428
commit
04871c511e
|
@ -5784,6 +5784,12 @@ libxlNodeDeviceDetachFlags(virNodeDevicePtr dev,
|
|||
|
||||
virCheckFlags(0, -1);
|
||||
|
||||
if (driverName && STRNEQ(driverName, "xen")) {
|
||||
virReportError(VIR_ERR_INVALID_ARG,
|
||||
_("unsupported driver name '%s'"), driverName);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(nodeconn = virGetConnectNodeDev()))
|
||||
goto cleanup;
|
||||
|
||||
|
@ -5815,13 +5821,7 @@ libxlNodeDeviceDetachFlags(virNodeDevicePtr dev,
|
|||
if (!pci)
|
||||
goto cleanup;
|
||||
|
||||
if (!driverName || STREQ(driverName, "xen")) {
|
||||
virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_XEN);
|
||||
} else {
|
||||
virReportError(VIR_ERR_INVALID_ARG,
|
||||
_("unsupported driver name '%s'"), driverName);
|
||||
goto cleanup;
|
||||
}
|
||||
virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_XEN);
|
||||
|
||||
if (virHostdevPCINodeDeviceDetach(hostdev_mgr, pci) < 0)
|
||||
goto cleanup;
|
||||
|
|
Loading…
Reference in New Issue