From patchwork Mon Nov 11 18:28:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 179120 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp7065125ilf; Mon, 11 Nov 2019 11:07:51 -0800 (PST) X-Google-Smtp-Source: APXvYqxChnIxDMtSeFGUh02IP/0KIsALGHbWtxmCGlWxZfQYPV7Y0/BuEWk6qIsEw78pZ8c1grBQ X-Received: by 2002:a17:906:7051:: with SMTP id r17mr23500628ejj.155.1573499271452; Mon, 11 Nov 2019 11:07:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573499271; cv=none; d=google.com; s=arc-20160816; b=cMCiuvqkc5cbtX3moUHwC9/wQDqb75ehwEcSLPbxNC21Zj58JD3hNh8avGCkMz6iBD BUlT97lhb025b4KHV9HjiOJCEf/BWY2GEy3RE2CTXVXpuUfH4gU9mDekQocQkYF6FNMv QD/W3yy004YqgwszliFRvnlCB1iIVw77nSw1kiA1VoXgmeW3f5zZ4Gh7EHVUtCbnObdH uJzong82Zp7EMPqcapu1oJQv0cKlJI/3Qi97/pYQXcbG2ddaEmRMy883SYoEwgCcqFGx O14NVUebUPt5rqrnnYx9sCHWSwdTn1YNMsMxMdFqPh0UY0oiPO2uw4ovjqncLijneVMw mb4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8QWhB3RV5b7bH2Nn8YXSHCymZWUlKKPs+dUhOqrCiy0=; b=v7WV93fwP3teFIBj1iToUyrLzHGd14nYmo59etX+eWq/zPNZri2Cnn55Ec6ctrdgOk kuVtDjJCRuDNPSOuGJ2QhKTKFmL5wgDM2Nj7arOgFUxpiVqaZHBBEjBuFRgrn3j48EkF zb+aXL190eFsCohjKznX+bcyKS7ge/0hHjvcmSR5/PJ6rQKRlw/8mg3vDhysVtYTxF2R mh1rzmBCgJm3P0+Ql1Iy02f/XX3BKH8ft245UqpB4Q1LMaFYFRH2UEQfnEu/a6SERRX7 5vf1vBLBRgQtyQQICU072RkiZk9c/n1tPvixGBztMHIf4lX2sjZFGhPncxkerrer7UW9 cp4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HieXN1De; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z26si9706222ejb.223.2019.11.11.11.07.51; Mon, 11 Nov 2019 11:07:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HieXN1De; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728897AbfKKTHs (ORCPT + 26 others); Mon, 11 Nov 2019 14:07:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:55912 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728169AbfKKShN (ORCPT ); Mon, 11 Nov 2019 13:37:13 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C156521655; Mon, 11 Nov 2019 18:37:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573497433; bh=LXXefkn7p8AQImuoepIaWvtbHVSn6+lPhVa3zsDkwBE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HieXN1DeKkp7EcbMy49/wKEMuPLRqFWlwF308j8l1vZQDRxMatP7DHrz1jVz/+ugi UbHpUwMe8SKbW41vel/S7PJJrUeLpmdF2UU2X/U2K2Ml9R4hbMix4z2as1ohK7IPKd ex5p30Zd+BSUu4B8D+7pdbprYxskWkf5MUA4CY6I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Kishon Vijay Abraham I , Bjorn Helgaas , Mathieu Poirier Subject: [PATCH 4.14 053/105] misc: pci_endpoint_test: Fix BUG_ON error during pci_disable_msi() Date: Mon, 11 Nov 2019 19:28:23 +0100 Message-Id: <20191111181443.403909088@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191111181421.390326245@linuxfoundation.org> References: <20191111181421.390326245@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kishon Vijay Abraham I commit b7636e816adcb52bc96b6fb7bc9d141cbfd17ddb upstream pci_disable_msi() throws a Kernel BUG if the driver has successfully requested an IRQ and not released it. Fix it here by freeing IRQs before invoking pci_disable_msi(). Signed-off-by: Kishon Vijay Abraham I Signed-off-by: Bjorn Helgaas Signed-off-by: Mathieu Poirier Signed-off-by: Greg Kroah-Hartman --- drivers/misc/pci_endpoint_test.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -92,6 +92,7 @@ struct pci_endpoint_test { void __iomem *bar[6]; struct completion irq_raised; int last_irq; + int num_irqs; /* mutex to protect the ioctls */ struct mutex mutex; struct miscdevice miscdev; @@ -514,6 +515,7 @@ static int pci_endpoint_test_probe(struc irq = pci_alloc_irq_vectors(pdev, 1, 32, PCI_IRQ_MSI); if (irq < 0) dev_err(dev, "failed to get MSI interrupts\n"); + test->num_irqs = irq; } err = devm_request_irq(dev, pdev->irq, pci_endpoint_test_irqhandler, @@ -581,6 +583,9 @@ err_iounmap: pci_iounmap(pdev, test->bar[bar]); } + for (i = 0; i < irq; i++) + devm_free_irq(dev, pdev->irq + i, test); + err_disable_msi: pci_disable_msi(pdev); pci_release_regions(pdev); @@ -594,6 +599,7 @@ err_disable_pdev: static void pci_endpoint_test_remove(struct pci_dev *pdev) { int id; + int i; enum pci_barno bar; struct pci_endpoint_test *test = pci_get_drvdata(pdev); struct miscdevice *misc_device = &test->miscdev; @@ -609,6 +615,8 @@ static void pci_endpoint_test_remove(str if (test->bar[bar]) pci_iounmap(pdev, test->bar[bar]); } + for (i = 0; i < test->num_irqs; i++) + devm_free_irq(&pdev->dev, pdev->irq + i, test); pci_disable_msi(pdev); pci_release_regions(pdev); pci_disable_device(pdev);