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: 9199913 X-Patchwork-Delegate: rjw@sisk.pl 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 2321F60752 for ; Mon, 27 Jun 2016 05:57:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 133682845C for ; Mon, 27 Jun 2016 05:57:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 05F3428576; Mon, 27 Jun 2016 05:57:22 +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 7DE1F2845C for ; Mon, 27 Jun 2016 05:57:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751196AbcF0F5U (ORCPT ); Mon, 27 Jun 2016 01:57:20 -0400 Received: from condef008-v.nifty.com ([210.131.4.245]:33520 "EHLO condef008-v.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750851AbcF0F5U (ORCPT ); Mon, 27 Jun 2016 01:57:20 -0400 X-Greylist: delayed 350 seconds by postgrey-1.27 at vger.kernel.org; Mon, 27 Jun 2016 01:57:19 EDT Received: from conuserg-09.nifty.com ([10.26.8.72])by condef008-v.nifty.com with ESMTP id u5R5ndgU014761 for ; Mon, 27 Jun 2016 14:49:39 +0900 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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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)); }