From: Alex Williamson Subject: [PATCH] device-assignment: Don't deassign when the assignment fails Date: Thu, 10 Jun 2010 10:20:15 -0600 Message-ID: <20100610162015.13106.3162.stgit@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: kvm@vger.kernel.org Return-path: Received: from qmta14.westchester.pa.mail.comcast.net ([76.96.59.212]:40633 "EHLO qmta14.westchester.pa.mail.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759313Ab0FJQUc (ORCPT ); Thu, 10 Jun 2010 12:20:32 -0400 Sender: kvm-owner@vger.kernel.org List-ID: The last thing assign_device() does is call into KVM_ASSIGN_PCI_DEVICE. If that fails, the device is not assigned, so we shouldn't then try to deassign it. If you try to assign the same device multiple times, you can get into a nasty fail-succeed-fail-succeed loop. And we certainly shouldn't take the assigned_out branch before we've even attempted to assign the device. Signed-off-by: Alex Williamson --- hw/device-assignment.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/device-assignment.c b/hw/device-assignment.c index 2b963b5..7e53a95 100644 --- a/hw/device-assignment.c +++ b/hw/device-assignment.c @@ -1407,12 +1407,12 @@ static int assigned_initfn(struct PCIDevice *pci_dev) if (pci_enable_capability_support(pci_dev, 0, NULL, assigned_device_pci_cap_write_config, assigned_device_pci_cap_init) < 0) - goto assigned_out; + goto out; /* assign device to guest */ r = assign_device(dev); if (r < 0) - goto assigned_out; + goto out; /* assign irq for the device */ r = assign_irq(dev);