From patchwork Sun Nov 12 12:28:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 10054761 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 5DBFE602A7 for ; Sun, 12 Nov 2017 12:29:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5FAB9298A8 for ; Sun, 12 Nov 2017 12:29:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 532DB298E2; Sun, 12 Nov 2017 12:29:04 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham 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 BE69F298A8 for ; Sun, 12 Nov 2017 12:29:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750735AbdKLM3B (ORCPT ); Sun, 12 Nov 2017 07:29:01 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:51058 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751186AbdKLM3A (ORCPT ); Sun, 12 Nov 2017 07:29:00 -0500 Received: by mail-lf0-f68.google.com with SMTP id a132so15483861lfa.7; Sun, 12 Nov 2017 04:28:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=tAR3OTa4bwKCZ9fh/8DjXjx/ncdjNNbvkHA2nn3bloY=; b=fHanTwbtBuBvkj36lhue2LprDoj9tpcSPl6mNGUJIFolXQHG/gDa7K8zXIePNON+q3 omgOVR8Vn1YbUwKoarKyYo6rhUlT5dK7qrDN5w4xdiOMKuADPpSiHWFjhwldxAUkfpeW 5sOSrdJ4yW4ec791S3MkPkqYL1/JEV6ISnLxHCpolmdddKadd6sO+m0zW87uo8QOf4X4 Wm/vSqWOuwWRXGYTPsIo9ZF86++eRh+glinY0OqmAhkbzuzHVKcvMhCQb6PxzJ6sAOei 4ng1A/Np1HUBXVHHvGoqgh7Ra8ESEzxv2xg/Cu00PsyRUwn0Ct8igxdiEjl30z0QGQIo UukQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=tAR3OTa4bwKCZ9fh/8DjXjx/ncdjNNbvkHA2nn3bloY=; b=nRTiLwZnk+Uw6I6N+Awe4lX70NDNxmMP2smnq83S1Eyg0hUEhSfqr5Xq5DhUfP5pUv yYZ6QynQa63GNguBoZZB2cl2SmGLmGLvCjh9ND6aQVxd4QerUczl/4pRru2M5POd5Fu5 LfaMnBbqEeFJ1FRfjnpWGV5xe9hjh4qTzVG66MZWjq5sO3E01H2rtvJneDCeB6Z3A/4y g9knrI9twzYLig2Nt3FGqMxrvaqjljXiu6Akca/X41XdqyTCJTOdDcBF7Erfd3u4QxaY 53P90xAfh+NH9oI/puZWKFzIc5fCbCwjZKclFxYYnHvU6yX1ppi+Ztn4AiL2GmlwK7qI NgXw== X-Gm-Message-State: AJaThX5HJpI1otAPTI8Eawgm+Zd03g3u5A2lDWyvAPU0Zvecq6PY+hgX VlcZwHVILCnGYMNPfHvwRWa+WbkP X-Google-Smtp-Source: AGs4zMYM0z/kz+hOQCyaO3G1JP4oAJP8ZyqijwkzttpbKuyjm6yBKOe3q+SRDic2ND26I/q/C//nCQ== X-Received: by 10.25.67.30 with SMTP id q30mr1853417lfa.118.1510489738518; Sun, 12 Nov 2017 04:28:58 -0800 (PST) Received: from xi.terra (c-c0bae655.07-184-6d6c6d4.cust.bredbandsbolaget.se. [85.230.186.192]) by smtp.gmail.com with ESMTPSA id r80sm1521434lfe.1.2017.11.12.04.28.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Nov 2017 04:28:57 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.89) (envelope-from ) id 1eDrNn-00081Y-0t; Sun, 12 Nov 2017 13:29:03 +0100 From: Johan Hovold To: Murali Karicheri Cc: Lorenzo Pieralisi , Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable Subject: [PATCH] PCI: keystone: fix interrupt-controller-node lookup Date: Sun, 12 Nov 2017 13:28:50 +0100 Message-Id: <20171112122850.30804-1-johan@kernel.org> X-Mailer: git-send-email 2.15.0 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 Fix child-node lookup during initialisation, which ended up searching the whole device tree depth-first starting at the parent rather than just matching on its children. To make things worse, the parent pci node was prematurely freed, while the child interrupt-controller node was leaked. Fixes: 0c4ffcfe1fbc ("PCI: keystone: Add TI Keystone PCIe driver") Cc: stable # 3.18 Cc: Murali Karicheri Acked-by: Murali Karicheri Acked-by: Lorenzo Pieralisi --- drivers/pci/dwc/pci-keystone.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/pci/dwc/pci-keystone.c b/drivers/pci/dwc/pci-keystone.c index 5bee3af47588..39405598b22d 100644 --- a/drivers/pci/dwc/pci-keystone.c +++ b/drivers/pci/dwc/pci-keystone.c @@ -178,7 +178,7 @@ static int ks_pcie_get_irq_controller_info(struct keystone_pcie *ks_pcie, } /* interrupt controller is in a child node */ - *np_temp = of_find_node_by_name(np_pcie, controller); + *np_temp = of_get_child_by_name(np_pcie, controller); if (!(*np_temp)) { dev_err(dev, "Node for %s is absent\n", controller); return -EINVAL; @@ -187,6 +187,7 @@ static int ks_pcie_get_irq_controller_info(struct keystone_pcie *ks_pcie, temp = of_irq_count(*np_temp); if (!temp) { dev_err(dev, "No IRQ entries in %s\n", controller); + of_node_put(*np_temp); return -EINVAL; } @@ -204,6 +205,8 @@ static int ks_pcie_get_irq_controller_info(struct keystone_pcie *ks_pcie, break; } + of_node_put(*np_temp); + if (temp) { *num_irqs = temp; return 0;