From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Williamson Subject: [PATCH 3/6] pci-assign: Fix PCI_EXP_FLAGS_TYPE shift Date: Wed, 16 Nov 2011 13:45:53 -0700 Message-ID: <20111116204547.23506.76421.stgit@bling.home> References: <20111116203834.23506.21535.stgit@bling.home> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Cc: jan.kiszka@siemens.com, alex.williamson@redhat.com, yongjie.ren@intel.com To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:38584 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752021Ab1KPUp5 (ORCPT ); Wed, 16 Nov 2011 15:45:57 -0500 In-Reply-To: <20111116203834.23506.21535.stgit@bling.home> Sender: kvm-owner@vger.kernel.org List-ID: Coverity found that we're doing (uint16_t)type & 0xf0 >> 8. This is obviously always 0x0, so our attempt to filter out some device types thinks everything is an endpoint. Fix shift amount. Signed-off-by: Alex Williamson --- hw/device-assignment.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/hw/device-assignment.c b/hw/device-assignment.c index 571a097..ec302d2 100644 --- a/hw/device-assignment.c +++ b/hw/device-assignment.c @@ -1294,7 +1294,7 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev) assigned_dev_setup_cap_read(dev, pos, size); type = pci_get_word(pci_dev->config + pos + PCI_EXP_FLAGS); - type = (type & PCI_EXP_FLAGS_TYPE) >> 8; + type = (type & PCI_EXP_FLAGS_TYPE) >> 4; if (type != PCI_EXP_TYPE_ENDPOINT && type != PCI_EXP_TYPE_LEG_END && type != PCI_EXP_TYPE_RC_END) { fprintf(stderr,