From bf450f5b3dc607a6d1f2e65002186dde37c5de84 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Fri, 7 Jun 2019 13:56:46 +0200 Subject: [PATCH] virHostdevPreparePCIDevices: Construct pcidevs list earlier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There's no need to translate virDomainHostdevDef-s into virPCIDevice-s with locked list of PCI devices. Signed-off-by: Michal Privoznik Reviewed-by: Ján Tomko --- src/util/virhostdev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index 5935d926aa..7b5ccf2daf 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -639,12 +639,12 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mgr, if (!nhostdevs) return 0; + if (!(pcidevs = virHostdevGetPCIHostDeviceList(hostdevs, nhostdevs))) + return -1; + virObjectLock(mgr->activePCIHostdevs); virObjectLock(mgr->inactivePCIHostdevs); - if (!(pcidevs = virHostdevGetPCIHostDeviceList(hostdevs, nhostdevs))) - goto cleanup; - /* Detaching devices from the host involves several steps; each * of them is described at length below. * @@ -912,9 +912,9 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr mgr, } cleanup: - virObjectUnref(pcidevs); virObjectUnlock(mgr->activePCIHostdevs); virObjectUnlock(mgr->inactivePCIHostdevs); + virObjectUnref(pcidevs); return ret; }