From patchwork Thu May 24 07:23:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10422947 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 3B27B602D8 for ; Thu, 24 May 2018 07:23:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25D6F29010 for ; Thu, 24 May 2018 07:23:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A04429016; Thu, 24 May 2018 07:23:38 +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 C278629010 for ; Thu, 24 May 2018 07:23:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935632AbeEXHXg (ORCPT ); Thu, 24 May 2018 03:23:36 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:50504 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935616AbeEXHXe (ORCPT ); Thu, 24 May 2018 03:23:34 -0400 Received: by mail-wm0-f68.google.com with SMTP id t11-v6so2179695wmt.0; Thu, 24 May 2018 00:23: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=VM4Gw8GuTm9uNYh47GTYF6azng1E6OQKiSD9QDLyFQY=; b=A49FFWZVDEMIQu4Q3SdvId+cZpmWXzQYcnrFa3xbPC8SoH9XOKd6yXHnhJuqgkZSXX v0YMeg/wetRKONyEhQxBlxLZdPHMf2EVDrCEkCC8ddpgBoZOnJuPEkyRCOIM/7qzyfyx MO3u5CH6Vxxw5UMjjdz6d/Lwzez6+quCmpSriUSsqfGOX5xgYT45NjYvcqXLlYcAvwev SxYga6JlccV806YXNU0XHJsVEd06LmlQca50CdUGz+b8bpLrb427qpi6Cdza6qIdLFEg tLEEWeMBWNgFx6ON9vM5/ftbthEIGkgGcpCmMnd5nR1EeLHnA516g++wI0/Tt0K/ExSt zpYg== 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=VM4Gw8GuTm9uNYh47GTYF6azng1E6OQKiSD9QDLyFQY=; b=FTy57YOWffKt+1x/r/3r3GaOdPvHgSdgMK9Cfyn1E/s5y7VcyZL658/Zu7FqaiK0qU do6EvQXVMPzbN6CHi4RZfiGqpRmSmW0Otj3gMuK1cC2qJoUDnpNzVdMxaH4MefH1mHER ByvKkaccI4QjDpstW/hcCfwm2e81GGZX8vQz0kJ329jxsr74ZU9TrqWvU140wfj3gmUt KsMcla3fCDgecq+yYUTzNvMc/CpRjh4jcpWmjEo2vPuGe/Wu6nscCSQlLlprxOyCsgRW mykhzs07uB7MmeZfx7cs5sFeo1vwdm/X4EZg2qWsmSQK4mhJ7PIcrZYJ4aByoGk9VieW X4KQ== X-Gm-Message-State: ALKqPwes+OnzcoyOZWNY8X7ndYO68ajepJjkzhdT+ooHCL6+OPUjWB8M 9jvK8bKVmXlfrihXnSI9AD01664H X-Google-Smtp-Source: AB8JxZpwHFNxRRmHzmjgyJexRHDfg9SxQX6XPP5ciaBSEGAX5FOMDGeDcf/SYJp/IR3ADsbdSYVe5Q== X-Received: by 2002:a7b:c011:: with SMTP id c17-v6mr7010861wmb.78.1527146613239; Thu, 24 May 2018 00:23: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 j13-v6sm10997919wre.38.2018.05.24.00.23.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 00:23:31 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: linux-pci@vger.kernel.org Cc: Marek Vasut , Geert Uytterhoeven , Phil Edworthy , Simon Horman , Wolfram Sang , linux-renesas-soc@vger.kernel.org Subject: [PATCH 2/6] PCI: rcar: Add missing irq_dispose_mapping() into failpath Date: Thu, 24 May 2018 09:23:19 +0200 Message-Id: <20180524072323.22115-2-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180524072323.22115-1-marek.vasut+renesas@gmail.com> References: <20180524072323.22115-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: Phil Edworthy Cc: Simon Horman Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org --- 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);