From patchwork Sat Jul 15 08:42:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 9842181 X-Patchwork-Delegate: eduardo.valentin@ti.com 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 8A6C2602BD for ; Sat, 15 Jul 2017 09:07:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F72B283C5 for ; Sat, 15 Jul 2017 09:07:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 631D828419; Sat, 15 Jul 2017 09:07:35 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 CED25283C5 for ; Sat, 15 Jul 2017 09:07:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751168AbdGOJHd (ORCPT ); Sat, 15 Jul 2017 05:07:33 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:2147 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751145AbdGOJHc (ORCPT ); Sat, 15 Jul 2017 05:07:32 -0400 X-IronPort-AV: E=Sophos;i="5.40,362,1496095200"; d="scan'208";a="283461798" Received: from palace.lip6.fr (HELO localhost.localdomain) ([132.227.105.202]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/AES128-SHA256; 15 Jul 2017 11:07:31 +0200 From: Julia Lawall To: Zhang Rui Cc: kernel-janitors@vger.kernel.org, Eduardo Valentin , Thierry Reding , Jonathan Hunter , linux-pm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] thermal: tegra: delete unneeded of_node_put Date: Sat, 15 Jul 2017 10:42:32 +0200 Message-Id: <1500108152-1812-1-git-send-email-Julia.Lawall@lip6.fr> 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 Device node iterators perform an of_node_put on each iteration, so putting an of_node_put before a continue results in a double put. The semantic match that finds this problem is as follows (http://coccinelle.lip6.fr): // @@ expression e1; local idexpression child; iterator name for_each_child_of_node; @@ for_each_child_of_node(e1,child) { ... when != of_node_get(child) * of_node_put(child); ... * continue; } // Furthermore, the call to thermal_of_cooling_device_register immediately calls __thermal_cooling_device_register with the same arguments. The latter function stores the device node argument, which is the second argument of for_each_child_of_node, in the returned thermal_cooling_device structure. This returned structure is then stored in the cdev field of stc. Thus it seems that the second argument of for_each_child_of_node escapes the scope of the for_each_child_of_node, so an explicit of_node_get on success of thermal_of_cooling_device_register is also needed. Signed-off-by: Julia Lawall --- drivers/thermal/tegra/soctherm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c index 7d2db23..10f4fdd 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c @@ -1014,7 +1014,6 @@ static void soctherm_init_hw_throt_cdev(struct platform_device *pdev) tcd = thermal_of_cooling_device_register(np_stcc, (char *)name, ts, &throt_cooling_ops); - of_node_put(np_stcc); if (IS_ERR_OR_NULL(tcd)) { dev_err(dev, "throttle-cfg: %s: failed to register cooling device\n", @@ -1022,6 +1021,7 @@ static void soctherm_init_hw_throt_cdev(struct platform_device *pdev) continue; } + of_node_get(np_stcc); stc->cdev = tcd; stc->init = true; }