From patchwork Mon Jun 27 05:50:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 70893 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp902849qgy; Sun, 26 Jun 2016 22:49:51 -0700 (PDT) X-Received: by 10.66.49.134 with SMTP id u6mr30488881pan.118.1467006591707; Sun, 26 Jun 2016 22:49:51 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d63si4866854pfb.168.2016.06.26.22.49.51; Sun, 26 Jun 2016 22:49:51 -0700 (PDT) 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; dkim=pass header.i=@nifty.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 S1751680AbcF0Ftj (ORCPT + 30 others); Mon, 27 Jun 2016 01:49:39 -0400 Received: from conuserg-09.nifty.com ([210.131.2.76]:59666 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750851AbcF0Fti (ORCPT ); Mon, 27 Jun 2016 01:49:38 -0400 Received: from beagle.diag.org (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-09.nifty.com with ESMTP id u5R5nE5B026359; Mon, 27 Jun 2016 14:49:15 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com u5R5nE5B026359 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1467006555; bh=mGEMXHWWjoDVTcvlNP2FfIe+jl+UdgvzBcwQjMdfuPw=; h=From:To:Cc:Subject:Date:From; b=icpdbnrmhrrIZXe7DTBSXt7s1wJI2tIPNQqAaO5Tr/eZE+wt96G9HJpsP0PCmQTZ+ rZ/R9SNTZnJAl2fK8ffr1S/MSaz+qW5G9+lkXCUxabTRZ2k6dAYE1Sjd/zkKun7sK1 ThE5He0OyROdt6fiEAlKmDMsLV1TZdK7nSfPdBavW0wH8pyF1vSaTYN5iMmESd1CMP Kg5ej8LYKx//lxcI4HiNvFt5u/3ZYVAoxYy5PMnRxVXBPuB8FGVze37tiAiPhd9z2o n7RBcAVSwXHqAkzZJDVQylYsBU0EGKMniu1d8pm9f5zRUpY2hYoAtFpu56SRah+Cv3 XVQszuQPswBWQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-pm@vger.kernel.org Cc: Viresh Kumar , Masahiro Yamada , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org Subject: [PATCH] cpufreq: dt: call of_node_put() before error out Date: Mon, 27 Jun 2016 14:50:13 +0900 Message-Id: <1467006613-24076-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If of_match_node() fails, this init function bails out without calling of_node_put(). I also changed of_node_put(of_root) to of_node_put(np); both of them hold the same pointer, but it seems better to call of_node_put() against the node returned by of_find_node_by_path(). Signed-off-by: Masahiro Yamada --- drivers/cpufreq/cpufreq-dt-platdev.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) -- 1.9.1 diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c b/drivers/cpufreq/cpufreq-dt-platdev.c index 3646b14..0bb44d5 100644 --- a/drivers/cpufreq/cpufreq-dt-platdev.c +++ b/drivers/cpufreq/cpufreq-dt-platdev.c @@ -79,15 +79,16 @@ static const struct of_device_id machines[] __initconst = { static int __init cpufreq_dt_platdev_init(void) { struct device_node *np = of_find_node_by_path("/"); + const struct of_device_id *match; if (!np) return -ENODEV; - if (!of_match_node(machines, np)) + match = of_match_node(machines, np); + of_node_put(np); + if (!match) return -ENODEV; - of_node_put(of_root); - return PTR_ERR_OR_ZERO(platform_device_register_simple("cpufreq-dt", -1, NULL, 0)); }