From patchwork Thu May 24 14:36:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10424927 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AAB4A6019D for ; Thu, 24 May 2018 14:36:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7B8529614 for ; Thu, 24 May 2018 14:36:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA9232951B; Thu, 24 May 2018 14:36:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58B842951B for ; Thu, 24 May 2018 14:36:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S970459AbeEXOg5 (ORCPT ); Thu, 24 May 2018 10:36:57 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:37952 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S970452AbeEXOgf (ORCPT ); Thu, 24 May 2018 10:36:35 -0400 Received: by mail-wr0-f195.google.com with SMTP id 94-v6so3568078wrf.5; Thu, 24 May 2018 07:36:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CsX2fXjIhW6AdP9tP4h0fWxpYZzaJ2XIwIMcRJ45/90=; b=TexUs9jLzKbI4eUNu5OLBz6KaA6OWXzhp0zE8qDj2R2q86BZi2TyY6F3mWKi/j4q4t 53raP7h3khxbCqpRH/UNE+k8UeVJi6mfczUcMvJP78L65Bw7GdIc1OeDPKDNU3GYk2Pz CDgGG/PToLsZvXQqSvFhiruxS3Hz2fX6YzXyl6l5freBYMVclwSdyBXPRTLIDcoYWHSp CcVxIeUSL6DUKRKLT5XEaNtq4oYya1aYsAysfEBk4Q9rbllya9MpxIBgIZ8DEjkuWbmd sf/97tMkDMPq06QgqP2WPvP47oCGLwf0fT6/CyDvP7HYBanLLv6shq/1UTdLsoswUAvx vZ/A== 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=CsX2fXjIhW6AdP9tP4h0fWxpYZzaJ2XIwIMcRJ45/90=; b=Wc8yscakadc9vOwEqUq+cl7rKKgCQgfVIiC+HL+RJ5xDrVhdOcPb+3ZIPUEXtwpPgQ WnOqHYLcYG2Q6yiF8ChRkB4STBVnSdUQTSoROigkROt2ffgh6GhE4AVekyPuL5HG5gtD uAzSoc+xt3DvOM6msERdp2OlBsJw+rcpbtInMmSUaZw+/m5vNPuzM3eG4Sg4DyKd01kC n1TsPkrJhY3cke+ZKSHhHykImlFB4zOL87viv3PkfCCWXRDDbsZhZVVzoNtp3JxqJV06 PD2/aiIVm7zBd2NtjizErZRVYKLLRjZnwzXgMM9ao2uHaUAD69ncpvyTtlviU3ql+Akg qz4g== X-Gm-Message-State: ALKqPweWGBm0N7Byx93benc7EGxZWUINM+FbLbePFqG/EgEvVd0NJ4hj iEmsehpI12IVsic+BQNe3pfgcY/t X-Google-Smtp-Source: AB8JxZqnwvEXTzORN6BF9ogXO90H+caqqunNy+tIXr6AmIwDmroMU5wKCcyeZJNXr+lJ/xgWm4aYvw== X-Received: by 2002:adf:988c:: with SMTP id w12-v6mr6187363wrb.215.1527172593725; Thu, 24 May 2018 07:36:33 -0700 (PDT) Received: from kurokawa.lan (ip-86-49-107-50.net.upcbroadband.cz. [86.49.107.50]) by smtp.gmail.com with ESMTPSA id x17-v6sm14348276wmd.46.2018.05.24.07.36.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 07:36:32 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: linux-pci@vger.kernel.org Cc: Marek Vasut , Geert Uytterhoeven , Lorenzo Pieralisi , Phil Edworthy , Simon Horman , Wolfram Sang , linux-renesas-soc@vger.kernel.org Subject: [PATCH v4 2/6] PCI: rcar: Add missing irq_dispose_mapping() into failpath Date: Thu, 24 May 2018 16:36:20 +0200 Message-Id: <20180524143624.26718-3-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180524143624.26718-1-marek.vasut+renesas@gmail.com> References: <20180524143624.26718-1-marek.vasut+renesas@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The rcar_pcie_get_resources() is another misnomer with a side effect. The function does not only get resources, but also maps MSI IRQs via irq_of_parse_and_map(). In case anything fails afterward, the IRQ mapping must be disposed through irq_dispose_mapping() which is not done. This patch handles irq_of_parse_and_map() failures in by disposing of the mapping in rcar_pcie_get_resources() as well as in probe. Signed-off-by: Marek Vasut Cc: Geert Uytterhoeven Cc: Lorenzo Pieralisi Cc: Phil Edworthy Cc: Simon Horman Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org Acked-by: Simon Horman --- V2: No change V3: No change V4: Rebase on top of Lorenzo's pci/rcar, fix up the rebase breakage induced by patches therein --- drivers/pci/host/pcie-rcar.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index 0879880f7975..6bb1cdec26be 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -950,18 +950,25 @@ static int rcar_pcie_get_resources(struct rcar_pcie *pcie) i = irq_of_parse_and_map(dev->of_node, 0); if (!i) { dev_err(dev, "cannot get platform resources for msi interrupt\n"); - return -ENOENT; + err = -ENOENT; + goto err_irq1; } pcie->msi.irq1 = i; i = irq_of_parse_and_map(dev->of_node, 1); if (!i) { dev_err(dev, "cannot get platform resources for msi interrupt\n"); - return -ENOENT; + err = -ENOENT; + goto err_irq2; } pcie->msi.irq2 = i; return 0; + +err_irq2: + irq_dispose_mapping(pcie->msi.irq1); +err_irq1: + return err; } static int rcar_pcie_inbound_ranges(struct rcar_pcie *pcie, @@ -1108,7 +1115,7 @@ static int rcar_pcie_probe(struct platform_device *pdev) err = clk_prepare_enable(pcie->bus_clk); if (err) { dev_err(dev, "failed to enable bus clock: %d\n", err); - goto err_pm_put; + goto err_unmap_msi_irqs; } err = rcar_pcie_parse_map_dma_ranges(pcie, dev->of_node); @@ -1151,6 +1158,10 @@ static int rcar_pcie_probe(struct platform_device *pdev) err_clk_disable: clk_disable_unprepare(pcie->bus_clk); +err_unmap_msi_irqs: + irq_dispose_mapping(pcie->msi.irq2); + irq_dispose_mapping(pcie->msi.irq1); + err_pm_put: pm_runtime_put(dev);