Received: by 10.223.185.116 with SMTP id b49csp1022209wrg; Wed, 21 Feb 2018 10:43:12 -0800 (PST) X-Google-Smtp-Source: AH8x226uYOdZqFKDjgOmvNrj8QpXksKYFMsh6x/IUVQkNIiEYOKvvK+STvWMMdSsITb8/CqzsD8P X-Received: by 2002:a17:902:8541:: with SMTP id d1-v6mr3968437plo.54.1519238592442; Wed, 21 Feb 2018 10:43:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519238592; cv=none; d=google.com; s=arc-20160816; b=FuTHVRqZg298dhpA3ZUCGotSWoJwMwN+Jrrolbo2nVt9EdNZzjDfQgEBV4YUTOaR6D +TkyH2W7vJ7c5PM9gaNuelHE0hVItXwphr0jqPx0ATd3KtQzAyFk+4eFZV6vvGhZJeaf o2mWF3PuiohSU1cChF9+cNIZSDZfOhvsCaK5X1JlDkPdjRp7aDnhJPxfk2IuUIL+hk4K XW2i1mmMy6qcBtmRXLaTNJHn3NvMadnDfLU7FbraI7abM+TZ39YRJnp4JU0dCsCszXYt MZeoOL0cRwikRSXcZw5tNXMQi79RZ2s6HTf6mJ6FJSLQHxK6Xk1ZBdFb1PoYRV51uS/W rjWQ== 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=lN9+M/0E6+Yglned9kcF0w1VCzjqkJ3McQwtjJH5+5w=; b=mcQBjI96JQr/Hg5f8XIcPGSWljDOE8WolXobnYch8x8ydobTSLrBbjIiVHYFkOihdL /WVEvXeY2EdcFTJcOPA9UodEKMXvDQHuXjs7fAiXaqb1rHb5oouWE245L4iva68lROGA Vk+CKpBbXowhK79xMbyqqILZ3aUIx0rYM2IKlgGIDx9f+WdSRciqjQsYdbySarYIDYhc tSSa8Z5Vta3dX76FQ0Qf6oPjhK6VbKov12NDSGxxCEo9XRrFJxYLo1xZoI9Qfb7uy4JZ zBtE6gmnLokjxF8kW1a+/GRkSHyPMSj/YLF3TeNHm6tP1il1TaT0E2tUPT2Ol8Btg3wb 0EgA== 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 j185si13764pfc.44.2018.02.21.10.42.58; Wed, 21 Feb 2018 10:43:12 -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 S936699AbeBUN1l (ORCPT + 99 others); Wed, 21 Feb 2018 08:27:41 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:44514 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936304AbeBUNLM (ORCPT ); Wed, 21 Feb 2018 08:11:12 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id D51A31247; Wed, 21 Feb 2018 13:10:58 +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 4.15 118/163] PCI: keystone: Fix interrupt-controller-node lookup Date: Wed, 21 Feb 2018 13:49:07 +0100 Message-Id: <20180221124536.658501195@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180221124529.931834518@linuxfoundation.org> References: <20180221124529.931834518@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 4.15-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 Signed-off-by: Greg Kroah-Hartman --- drivers/pci/dwc/pci-keystone.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- 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_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); return -EINVAL; @@ -187,6 +187,7 @@ static int ks_pcie_get_irq_controller_in 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_in break; } + of_node_put(*np_temp); + if (temp) { *num_irqs = temp; return 0;