From patchwork Fri Nov 17 13:38:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 10062795 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 E7DF46023A for ; Fri, 17 Nov 2017 13:56:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8A0F2AC06 for ; Fri, 17 Nov 2017 13:56:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD32D2ACD4; Fri, 17 Nov 2017 13:56:05 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 455CC2AC06 for ; Fri, 17 Nov 2017 13:56:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=YnD/VbagUkTBn6JECruXdtTug73KH1PfDUoVo755nJ0=; b=lDs NveOpYOVxK+ER9By5zfADM3H7rK8zA4niR1j3/YMuObdBWPuG5DzlpUV7pngWlFgXW/Qb/zp614Cs 3TePJ1gZfC4sq5vhPnKgKj5xCFUEpyXI2OSwEhdpG7Cy4rkINGH9R8wJ1VSLhpy3li9Ukql+Ye0l9 kZTaSy9n7/05WnRCJBNjP6DxcX2alETJNJg6HK6fR/SJm37cXpZadfByvmy4/x/9lvwgnaQwTFGIA 5qrKk8cJGHojvdxKRB+nUOUDKwN/RAr0Ia5URJAK9kVOa78UiqAZwLkfLxaqDYYMG97HmqfhqTnvb k/Sij7m9SZGEShU8/M6gBqpU/euqZrw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eFh7k-0003Th-3e; Fri, 17 Nov 2017 13:56:04 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eFh6I-0000zD-HF for linux-arm-kernel@bombadil.infradead.org; Fri, 17 Nov 2017 13:54:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=5a1WBjC1BvIQA7EUQqCUM5qG4tmUDS6xvYo5IQr8e4k=; b=KVMBuARWyndDq87yG6V2Nnb4C 1kIYH3UrKqg7xM8dZxzFe7vuMZVlGtJ/wXve7EX3s3C2p45yAQ9wqRxeTo3dm69DZkL7IIfSHGFHF TfgJa6TERm4GChzsXhR55MMy4EEUR5m9yb/eBeyW8/XI9p1rvjtnEpUswCUfOgc0neDzukC6FJgno +aYUZY5/aKDZz7l5gGBwGCnoyo3nusfiQ5OF8et7HLryx+VfYX0wL5KzNAZ6Evt+zREnSjwlLiCMP IhIjQ+g7QLbQPy+aadhp0N0RWIc9sCUEJF/YOrcJU1uv9VgwSlNPq8/GiZsxnd8BBoJjWUM1nYx7x D5zFD4sAQ==; Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eFgri-0003hg-P1 for linux-arm-kernel@lists.infradead.org; Fri, 17 Nov 2017 13:39:33 +0000 Received: by mail-lf0-x243.google.com with SMTP id i14so2739686lfc.1 for ; Fri, 17 Nov 2017 05:39:10 -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=5a1WBjC1BvIQA7EUQqCUM5qG4tmUDS6xvYo5IQr8e4k=; b=u5AZ5QxFUeG6s+MJXdrnt5KWPXaLNXM9ulX4dlueNHn2DNARKtNBFoNHze4+rxADc5 D/qNUfMl/Otga7JQr9/5Y30ii/8Uz5jn+jgGrl15NuyfyO3q4QvhIgx3HRawiwGdLhLL cMlgt4e+jYnEaJ/Kyg6bT3jBehPaZINdYjBSuIBpj6zQyp4vAYYTFnZTcY11bosEk+QU PiviLmUAOEEikJQp6tXmcDyczalbuvQTfyvUcbxrG7IzuBtvULWuRROdH3Ze6pgc2nsx L4OPlkRRrJZqHFp30IN2Yg+GSmjUdOGuvwYOWqy0bUz2y5NOyakJI5yrilFiE0Pbe0Rp ccYw== 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=5a1WBjC1BvIQA7EUQqCUM5qG4tmUDS6xvYo5IQr8e4k=; b=KL18VQ+IeWqnd9em0N/VZGMvef7vG07hJaoSntqZD9Xqlb5z69lWqVsC1hBad5J66i uigG0zIAJNttMi48c51aWCDzBCTE+atIwhYHVTLicDNW5iOslnS7apNTzXz2fTcKdWuQ oJBwA8gcqWnFplTsfSgkYkUe+qy5eWjnC5wOpvUMYoNVWCfL5yaRpXaw0l/08h1JbF7G p5uHlfq6s1WDzmnDaxYswdY1OaC6OXdQubsy4Ky48eaTklHjlpC2lLFmiBCpMDzU6f8x 6hPsnxcyDo03cGcyLMEq58aebuynqIOPGnsdv5VDFjLAPVA7GWJMmL0JP6WVmfz1hJxt J9bQ== X-Gm-Message-State: AJaThX6XWU/uOyuxZP7vatVQq30p5vy5aXjJZxujO2ae+UEggw15de3r 4f8jL0wr9QGQPtPsHBcqb1U= X-Google-Smtp-Source: AGs4zMZxqO0vY8S+MHzfDqqIedI42V+LRQBi6npRDhbJuYWycTA3QJXPJDvRxZynh2lxMh+YD8zDSw== X-Received: by 10.25.199.139 with SMTP id x133mr894015lff.87.1510925948612; Fri, 17 Nov 2017 05:39:08 -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 f13sm889009lja.25.2017.11.17.05.39.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Nov 2017 05:39:07 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.89) (envelope-from ) id 1eFgrK-0000Lj-Ne; Fri, 17 Nov 2017 14:39:06 +0100 From: Johan Hovold To: Murali Karicheri Subject: [PATCH v2] PCI: keystone: fix interrupt-controller-node lookup Date: Fri, 17 Nov 2017 14:38:31 +0100 Message-Id: <20171117133831.1300-1-johan@kernel.org> X-Mailer: git-send-email 2.15.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171117_133930_878929_853E0500 X-CRM114-Status: GOOD ( 11.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Pieralisi , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, stable , Johan Hovold , Bjorn Helgaas , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Lorenzo Pieralisi Signed-off-by: Johan Hovold --- v2 - amend commit message and mention explicitly that of_find_node_by_name() drops a reference to the start node - add Murali's and Lorenzo's acks 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;