From patchwork Wed Nov 11 00:28:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Herrenschmidt X-Patchwork-Id: 542712 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 544E314017E for ; Wed, 11 Nov 2015 11:53:01 +1100 (AEDT) Received: from localhost ([::1]:36652 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwJel-0001n7-8U for incoming@patchwork.ozlabs.org; Tue, 10 Nov 2015 19:52:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38328) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwJJW-0003IJ-HP for qemu-devel@nongnu.org; Tue, 10 Nov 2015 19:31:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZwJJT-0004iq-9N for qemu-devel@nongnu.org; Tue, 10 Nov 2015 19:31:02 -0500 Received: from gate.crashing.org ([63.228.1.57]:48689) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwJJR-0004i0-ON; Tue, 10 Nov 2015 19:30:59 -0500 Received: from pasglop.ozlabs.ibm.com. (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.13.8) with ESMTP id tAB0Sb31024031; Tue, 10 Nov 2015 18:30:37 -0600 From: Benjamin Herrenschmidt To: qemu-ppc@nongnu.org Date: Wed, 11 Nov 2015 11:28:00 +1100 Message-Id: <1447201710-10229-48-git-send-email-benh@kernel.crashing.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1447201710-10229-1-git-send-email-benh@kernel.crashing.org> References: <1447201710-10229-1-git-send-email-benh@kernel.crashing.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 63.228.1.57 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 47/77] pci: Don't call pci_irq_handler() for a negative intx X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Under some circumstances, pci_intx() can return -1 (when the interrupt pin in the config space is 0 which normally means no interrupt). I have seen cases of pci_set_irq() being called on such devices, in turn causing pci_irq_handler() to be called with "-1" as an argument which doesn't seem like a terribly good idea. Signed-off-by: Benjamin Herrenschmidt --- hw/pci/pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 7003f7c..b364eff 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1298,7 +1298,9 @@ qemu_irq pci_allocate_irq(PCIDevice *pci_dev) void pci_set_irq(PCIDevice *pci_dev, int level) { int intx = pci_intx(pci_dev); - pci_irq_handler(pci_dev, intx, level); + if (intx >= 0) { + pci_irq_handler(pci_dev, intx, level); + } } /* Special hooks used by device assignment */