From patchwork Wed Apr 12 07:12:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?C=C3=A9dric_Le_Goater?= X-Patchwork-Id: 749778 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3w2w9r02fjz9sNK for ; Wed, 12 Apr 2017 17:13:04 +1000 (AEST) Received: from localhost ([::1]:42561 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cyCSb-00050G-HI for incoming@patchwork.ozlabs.org; Wed, 12 Apr 2017 03:13:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40654) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cyCSK-00050A-6Q for qemu-devel@nongnu.org; Wed, 12 Apr 2017 03:12:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cyCSG-0005eT-6j for qemu-devel@nongnu.org; Wed, 12 Apr 2017 03:12:44 -0400 Received: from 8.mo178.mail-out.ovh.net ([46.105.74.227]:60360) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cyCSG-0005eF-0Q for qemu-devel@nongnu.org; Wed, 12 Apr 2017 03:12:40 -0400 Received: from player715.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo178.mail-out.ovh.net (Postfix) with ESMTP id A249031615 for ; Wed, 12 Apr 2017 09:12:38 +0200 (CEST) Received: from zorba.kaod.org.com (LFbn-1-10647-27.w90-89.abo.wanadoo.fr [90.89.233.27]) (Authenticated sender: clg@kaod.org) by player715.ha.ovh.net (Postfix) with ESMTPSA id 557971C0074; Wed, 12 Apr 2017 09:12:34 +0200 (CEST) From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: "Michael S. Tsirkin" Date: Wed, 12 Apr 2017 09:12:17 +0200 Message-Id: <1491981137-32713-1-git-send-email-clg@kaod.org> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Ovh-Tracer-Id: 15232862792762559449 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeeliedrudehgdduudelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.74.227 Subject: [Qemu-devel] [PATCH] pci: Don't call pci_irq_handler() for a negative intx X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marcel Apfelbaum , qemu-devel@nongnu.org, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Benjamin Herrenschmidt 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 [clg: updated for qemu-2.9 ] Signed-off-by: Cédric Le Goater Reviewed-by: David Gibson --- hw/pci/pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) Index: qemu-powernv-2.9.git/hw/pci/pci.c =================================================================== --- qemu-powernv-2.9.git.orig/hw/pci/pci.c +++ qemu-powernv-2.9.git/hw/pci/pci.c @@ -1419,7 +1419,9 @@ qemu_irq pci_allocate_irq(PCIDevice *pci 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 */