From patchwork Tue Oct 9 18:08:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 1571041 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 7DB81E00AF for ; Tue, 9 Oct 2012 18:09:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756743Ab2JISJN (ORCPT ); Tue, 9 Oct 2012 14:09:13 -0400 Received: from cantor2.suse.de ([195.135.220.15]:56360 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756733Ab2JISJG (ORCPT ); Tue, 9 Oct 2012 14:09:06 -0400 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id BC6CEA3DDD; Tue, 9 Oct 2012 20:09:05 +0200 (CEST) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: kvm@vger.kernel.org Cc: Marcelo Tosatti , Alex Williamson , Avi Kivity , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [PATCH stable-0.15 2/6] pci-assign: Fix PCI_EXP_FLAGS_TYPE shift Date: Tue, 9 Oct 2012 20:08:49 +0200 Message-Id: <1349806133-1916-3-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1349806133-1916-1-git-send-email-afaerber@suse.de> References: <1349806133-1916-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Alex Williamson 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 Signed-off-by: Avi Kivity (cherry picked from commit b4eccd18591f3d639bc3c923e299b3c1241a0b3f) Signed-off-by: Andreas Färber --- hw/device-assignment.c | 2 +- 1 Datei geändert, 1 Zeile hinzugefügt(+), 1 Zeile entfernt(-) diff --git a/hw/device-assignment.c b/hw/device-assignment.c index 177daa4..dc41bfd 100644 --- a/hw/device-assignment.c +++ b/hw/device-assignment.c @@ -1459,7 +1459,7 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev) } 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,