Received: by 10.223.185.116 with SMTP id b49csp4206012wrg; Mon, 26 Feb 2018 13:09:54 -0800 (PST) X-Google-Smtp-Source: AH8x224gBebnXfKAJoQ7GbKtSkfXWhrE1PZ8/PYyi1kW/audMRrX7HNbBekpmixSwgsf1PxIeOQi X-Received: by 2002:a17:902:5481:: with SMTP id e1-v6mr11890383pli.300.1519679394235; Mon, 26 Feb 2018 13:09:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519679394; cv=none; d=google.com; s=arc-20160816; b=WGj1ju+wbm8kqx8dqOF04LDiuz9MuViExWAFi6J0fYvz2bwjT8JIBpLEOACRL21fps 2zdzpyc+rApHKGcVuBLFhVN0tVnUtrJ+mI+ZY9sn4LdWrMjs7ezzp1udEA0u7iiLI0bi voJ8XXu861SVTXQQpdy3r89CwKm66j0KRxcu8xfX/vsMPYLDHQuV+0uVqHz8VnYd6xEh D+Fk5ymH1N5QqtW/RVH9Gw4jVoTlgSUnj0qX9HEGeOvEN65im9yrjHUh+b5ffPKRiEFA oUDZtGcfyG85EQctYaOpjl82xje4neg1lvBVXJuc/T49hBsTZYrl/AjtdzkFwDxrOPkT Horg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=/o/bdl/UNwgsMkUw/2+A2C8I9+GdpvkcjZM6pcmuyNE=; b=voCpbv0x+zCYlq4+lHro8WT5TReRWCxbZIkrFIn8Fq20RFmFUMPBF/KNp0LQtDDHYK QCb3y0iAk3nr4av2ktt7x+qAYFiniKO+DNpdoCNnMLP6enKmDw8uSBj9uOFNr4QHLTRt pWmX0niCfZj1Ya8G1ARallEW1s2aLOBxxRxuWK9B5ycmxU08v7fHSZ7WPN+bj+FueQso xJtSVNXeIqr4YnhtzxkEevOK2KqdIID5g9z22wX+sSM+GWBdxTMufuWJT7NirVezkkv+ wEYPLLfWReJ2PmxTZ8wEejYp19yd+/VGuNDneaHf/JXbOJKvxnZpZW+NsZzRvZyNY5/d hCig== ARC-Authentication-Results: i=1; mx.google.com; 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 v191si5839098pgd.807.2018.02.26.13.09.37; Mon, 26 Feb 2018 13:09:54 -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; 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 S1752189AbeBZVHX (ORCPT + 99 others); Mon, 26 Feb 2018 16:07:23 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:58918 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751733AbeBZUQO (ORCPT ); Mon, 26 Feb 2018 15:16:14 -0500 Received: from localhost (clnet-b04-243.ikbnet.co.at [83.175.124.243]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 176E4FE5; Mon, 26 Feb 2018 20:16:03 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Murali Karicheri , Johan Hovold , Lorenzo Pieralisi Subject: [PATCH 3.18 02/13] PCI: keystone: Fix interrupt-controller-node lookup Date: Mon, 26 Feb 2018 21:15:30 +0100 Message-Id: <20180226201527.354817968@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180226201527.242286068@linuxfoundation.org> References: <20180226201527.242286068@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Johan Hovold commit eac56aa3bc8af3d9b9850345d0f2da9d83529134 upstream. Fix child-node lookup during initialisation which was using the wrong OF-helper and 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 could end up being prematurely freed as of_find_node_by_name() drops a reference to its first argument. Any matching child interrupt-controller node was also leaked. Fixes: 0c4ffcfe1fbc ("PCI: keystone: Add TI Keystone PCIe driver") Cc: stable # 3.18 Acked-by: Murali Karicheri Signed-off-by: Johan Hovold [lorenzo.pieralisi@arm.com: updated commit subject] Signed-off-by: Lorenzo Pieralisi [johan: backport to 4.4] Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/pci/host/pci-keystone.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- a/drivers/pci/host/pci-keystone.c +++ b/drivers/pci/host/pci-keystone.c @@ -179,14 +179,16 @@ static int ks_pcie_get_irq_controller_in } /* 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); goto out; } temp = of_irq_count(*np_temp); - if (!temp) + if (!temp) { + of_node_put(*np_temp); goto out; + } if (temp > max_host_irqs) dev_warn(dev, "Too many %s interrupts defined %u\n", (legacy ? "legacy" : "MSI"), temp); @@ -200,6 +202,9 @@ static int ks_pcie_get_irq_controller_in if (host_irqs[temp] < 0) break; } + + of_node_put(*np_temp); + if (temp) { *num_irqs = temp; ret = 0;