mirror of https://github.com/xemu-project/xemu.git
pcie_sriov: unregister_vfs(): fix error path
local_err must be NULL before calling object_property_set_bool(), so we must clear it on each iteration. Let's also use more convenient error_reportf_err(). Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Message-Id: <20230925194040.68592-8-vsementsov@yandex-team.ru> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
cf0386509e
commit
f1a153857a
|
@ -196,19 +196,16 @@ static void register_vfs(PCIDevice *dev)
|
||||||
|
|
||||||
static void unregister_vfs(PCIDevice *dev)
|
static void unregister_vfs(PCIDevice *dev)
|
||||||
{
|
{
|
||||||
Error *local_err = NULL;
|
|
||||||
uint16_t num_vfs = dev->exp.sriov_pf.num_vfs;
|
uint16_t num_vfs = dev->exp.sriov_pf.num_vfs;
|
||||||
uint16_t i;
|
uint16_t i;
|
||||||
|
|
||||||
trace_sriov_unregister_vfs(dev->name, PCI_SLOT(dev->devfn),
|
trace_sriov_unregister_vfs(dev->name, PCI_SLOT(dev->devfn),
|
||||||
PCI_FUNC(dev->devfn), num_vfs);
|
PCI_FUNC(dev->devfn), num_vfs);
|
||||||
for (i = 0; i < num_vfs; i++) {
|
for (i = 0; i < num_vfs; i++) {
|
||||||
|
Error *err = NULL;
|
||||||
PCIDevice *vf = dev->exp.sriov_pf.vf[i];
|
PCIDevice *vf = dev->exp.sriov_pf.vf[i];
|
||||||
object_property_set_bool(OBJECT(vf), "realized", false, &local_err);
|
if (!object_property_set_bool(OBJECT(vf), "realized", false, &err)) {
|
||||||
if (local_err) {
|
error_reportf_err(err, "Failed to unplug: ");
|
||||||
fprintf(stderr, "Failed to unplug: %s\n",
|
|
||||||
error_get_pretty(local_err));
|
|
||||||
error_free(local_err);
|
|
||||||
}
|
}
|
||||||
object_unparent(OBJECT(vf));
|
object_unparent(OBJECT(vf));
|
||||||
object_unref(OBJECT(vf));
|
object_unref(OBJECT(vf));
|
||||||
|
|
Loading…
Reference in New Issue