From patchwork Fri Dec 3 19:34:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 378831 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oB3JYGtH026526 for ; Fri, 3 Dec 2010 19:34:16 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753208Ab0LCTeN (ORCPT ); Fri, 3 Dec 2010 14:34:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33527 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752582Ab0LCTeN (ORCPT ); Fri, 3 Dec 2010 14:34:13 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oB3JYDPW022734 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 3 Dec 2010 14:34:13 -0500 Received: from s20.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oB3JYC3d002382; Fri, 3 Dec 2010 14:34:12 -0500 From: Alex Williamson Subject: [PATCH 4/5] device-assignment: Error checking when adding capabilities To: kvm@vger.kernel.org Cc: alex.williamson@redhat.com, ddutile@redhat.com, mst@redhat.com, chrisw@redhat.com Date: Fri, 03 Dec 2010 12:34:12 -0700 Message-ID: <20101203193403.3579.52459.stgit@s20.home> In-Reply-To: <20101203192343.3579.73722.stgit@s20.home> References: <20101203192343.3579.73722.stgit@s20.home> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 03 Dec 2010 19:34:16 +0000 (UTC) diff --git a/hw/device-assignment.c b/hw/device-assignment.c index 6d6e657..838bf89 100644 --- a/hw/device-assignment.c +++ b/hw/device-assignment.c @@ -1288,7 +1288,7 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev) { AssignedDevice *dev = container_of(pci_dev, AssignedDevice, dev); PCIRegion *pci_region = dev->real_device.regions; - int pos; + int ret, pos; /* Clear initial capabilities pointer and status copied from hw */ pci_set_byte(pci_dev->config + PCI_CAPABILITY_LIST, 0); @@ -1302,8 +1302,10 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev) * MSI capability is the 1st capability in capability config */ if ((pos = pci_find_cap_offset(pci_dev, PCI_CAP_ID_MSI))) { dev->cap.available |= ASSIGNED_DEVICE_CAP_MSI; - pci_add_capability(pci_dev, PCI_CAP_ID_MSI, pos, - PCI_CAPABILITY_CONFIG_MSI_LENGTH); + if ((ret = pci_add_capability(pci_dev, PCI_CAP_ID_MSI, pos, + PCI_CAPABILITY_CONFIG_MSI_LENGTH)) < 0) { + return ret; + } /* Only 32-bit/no-mask currently supported */ pci_set_word(pci_dev->config + pos + PCI_MSI_FLAGS, @@ -1326,8 +1328,10 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev) uint32_t msix_table_entry; dev->cap.available |= ASSIGNED_DEVICE_CAP_MSIX; - pci_add_capability(pci_dev, PCI_CAP_ID_MSIX, pos, - PCI_CAPABILITY_CONFIG_MSIX_LENGTH); + if ((ret = pci_add_capability(pci_dev, PCI_CAP_ID_MSIX, pos, + PCI_CAPABILITY_CONFIG_MSIX_LENGTH)) < 0) { + return ret; + } pci_set_word(pci_dev->config + pos + PCI_MSIX_FLAGS, pci_get_word(pci_dev->config + pos + PCI_MSIX_FLAGS) &