From patchwork Thu Sep 5 16:17:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 173167 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp936062ilq; Thu, 5 Sep 2019 09:19:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqzVNgeNAi1cup3NLf4feEXf5CpDT7kvdAhqvzOvT0PkLGDusRPJf0MLJWNwPJ0krBek77jj X-Received: by 2002:a17:902:9f82:: with SMTP id g2mr4404014plq.63.1567700341946; Thu, 05 Sep 2019 09:19:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567700341; cv=none; d=google.com; s=arc-20160816; b=LBrORO7EEA+lEAmy3cJA7EpWxfaDV6my9xpJdwwzP+1ZW6iwBXzlzPIqQi+VDVDJYU qrcqBNlfEy790KOkTfKWRQdQ8PfcDM/J9HjtT2NtqjVEY0x8LztfxLCp2Y75iZkmDj1E /Sz1STo6jl3tMOraTjOjncD5fOPXRKaOQDDKjeGw6H9q7SyGjXZav0dhwolE4Xee/rpw mQ4dJB6rP/bc9ygIQI0KUOa+u/jKXDXo21NL24UiCyyo+EvI99PHl9Fv69qZwJUUyoZR ROS4x4s2K5DQOGus3t53s0Sctitpx2LgcRx/o5jRBWAqSx7Kd7/sRbmYcGo1jQ9BlxdJ KUiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=tpqdWISBmI7/K+eXW/BM3B61WGwPfixYNx9jyTHk1dU=; b=yIkmiJFDeRAGuIhDoCqb2PZUhA/bSRYEtsNkQI+VdqQqnK4qG9Tjt708B62JU2tWrJ W3YFTSPXA7pFlCaRF0lfqd0M4IUEUmdV1GF5tGRp6g58TVM2/P3Nsywd6wWBAeVIQQuX qKgmdlX2h3CJP2reHAl0lAY6/ZD3ArUkqCXqmia5XyI6wL/P6nKxAKmWJyt368K2Ihkb NgKrdQN2ijEJNYnWY8TYuuqiCppS53PrGrj4ubeBHxpCqi5vqZLg5EdjEi3mexUIJtVN V14vOGNI/4He50S9WQ7AEoqYATVWM2GAD8pRlOTn5J2/1atk7ggjxApOiQFKjuiOPN62 HExQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K5DiiY2F; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b6si2276359pge.44.2019.09.05.09.19.01; Thu, 05 Sep 2019 09:19:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-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=@linaro.org header.s=google header.b=K5DiiY2F; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388442AbfIEQSP (ORCPT + 5 others); Thu, 5 Sep 2019 12:18:15 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:38108 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388334AbfIEQSP (ORCPT ); Thu, 5 Sep 2019 12:18:15 -0400 Received: by mail-pf1-f194.google.com with SMTP id h195so2075907pfe.5 for ; Thu, 05 Sep 2019 09:18:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tpqdWISBmI7/K+eXW/BM3B61WGwPfixYNx9jyTHk1dU=; b=K5DiiY2Fgz6MUrPKTtz10HsJkolwwVvGrdqBD69mgIMaQbkMXiTRCgCbb2ZyUxaTSS TsurgVMOb8XwbIXgdyeF+rfzsvnXsAM1sHLEQ4y5Ke840f0eEdtxvvN3Pb5ZdVwNLiXE UV+r4cWr5AN6DgFXtNn2GrDrgfsbA6uZcFqrnHfIbgan0lx/1+ZKIyh6gDp63fdh/v9I KCxMrdpVzkF4eB9dCxcnzu4IORv5zjU09dggJmJTVefvcrHEGmUqyNXgA3hCndJldZef 81oH34LbhykA0VcHebAOIDd2RLBykltXAikm9fusMU2Bx4GGt+Kmw89s92q1rKZ+QSBQ hcng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tpqdWISBmI7/K+eXW/BM3B61WGwPfixYNx9jyTHk1dU=; b=ZPRvt+xL8h2o7N4L39NLKNAh3K1CoALHZIw1Kg+zPN+RWMUN3kCFarFuuP0P6ycLW+ IuN/ENyk6VJSYeZw+J+bY3hpivIHf5l8qxmq+JCZ4zdzw79qNXBkAUAHgLCXMvPdw8Z2 P4kJhh01OqZhVZmGLRgI3GPr/8P+k0ZQnjMV6YIaUqY+dDrpe3xx/0IPX+/bI0i/08lc rRFLP+6S8pzMsPbCDgapg2zB+RCtaH671E/XIC32TFcGKC1fHcl+obGkQt8GrURNcjQ0 S8clTrHBTkZN9oAs+KB6+9DKVlAHk031hrFtoFIt85PYAT8Z5gCCDYXsh+gpiuHMEUSC W0tw== X-Gm-Message-State: APjAAAWqU6DVzPYXeUdZtZziDmNWFZJamz6u34mZ1UBj/Hn0XhO9Ifpy cp1iYixgqnm9ozwv3a7pF+UcAg== X-Received: by 2002:aa7:8e08:: with SMTP id c8mr849847pfr.238.1567700294324; Thu, 05 Sep 2019 09:18:14 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id m129sm6324005pga.39.2019.09.05.09.18.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2019 09:18:13 -0700 (PDT) From: Mathieu Poirier To: stable@vger.kernel.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-pci@vger.kernel.org, linux-mtd@lists.infradead.org Subject: [BACKPORT 4.14.y 11/18] misc: pci_endpoint_test: Fix BUG_ON error during pci_disable_msi() Date: Thu, 5 Sep 2019 10:17:52 -0600 Message-Id: <20190905161759.28036-12-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190905161759.28036-1-mathieu.poirier@linaro.org> References: <20190905161759.28036-1-mathieu.poirier@linaro.org> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@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 --- drivers/misc/pci_endpoint_test.c | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.17.1 diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index 504fa680825d..230f1e8538dc 100644 --- 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(struct pci_dev *pdev, 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 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev, 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 @@ static int pci_endpoint_test_probe(struct pci_dev *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(struct pci_dev *pdev) 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);