From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 430E3CE7A8D for ; Sun, 24 Sep 2023 13:21:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230336AbjIXNV3 (ORCPT ); Sun, 24 Sep 2023 09:21:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229737AbjIXNU5 (ORCPT ); Sun, 24 Sep 2023 09:20:57 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22C9F1BE7; Sun, 24 Sep 2023 06:18:29 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21EC5C43395; Sun, 24 Sep 2023 13:18:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695561508; bh=l5DnyFuuiHFzaawxIuRGJaUElNH7zX3N6SPI0DudOqg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oSCaXQzyI/1XWlfL9nUrQXa83K7SFgrUJYiJGHzVv0iklIDsbbpnpniK/Xs868Daj NHeu0HaJubHeOLl1cu5kMIi3x1QBv3fdZfNSs6up+aTaDsEg7C6lg3uSV83EHUM65Y xZgxUxDlv86wEVsCXEVMGJryWvupxGMGlFKEH2Dx5xG5II/LLrmgEUZ5H5Dion9573 2dk/VZr/2+SXzwb4cxJSpZIm3P9/7TCW17/BOOsv8DNTJH1FfEx/TJcHSz/PKkhEzV aUbFRLYikIXMt60fgdJPAgQlXGcbS3JvYKrlC1kZ8890b1qX+y7wJkQsIkJHTVkldp jsUv44VEMAN4Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Julia Lawall , "Rafael J . Wysocki" , Sasha Levin , rafael@kernel.org, daniel.lezcano@linaro.org, linux-pm@vger.kernel.org Subject: [PATCH AUTOSEL 6.1 19/28] thermal/of: add missing of_node_put() Date: Sun, 24 Sep 2023 09:17:36 -0400 Message-Id: <20230924131745.1275960-19-sashal@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230924131745.1275960-1-sashal@kernel.org> References: <20230924131745.1275960-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.55 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Julia Lawall [ Upstream commit 8a81cf96f5510aaf9a65d103f7405079a7b0fcc5 ] for_each_child_of_node performs an of_node_get on each iteration, so a break out of the loop requires an of_node_put. This was done using the Coccinelle semantic patch iterators/for_each_child.cocci Signed-off-by: Julia Lawall Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/thermal/thermal_of.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 762d1990180bf..4104743dbc17e 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -149,8 +149,10 @@ static int of_find_trip_id(struct device_node *np, struct device_node *trip) */ for_each_child_of_node(trips, t) { - if (t == trip) + if (t == trip) { + of_node_put(t); goto out; + } i++; } @@ -519,8 +521,10 @@ static int thermal_of_for_each_cooling_maps(struct thermal_zone_device *tz, for_each_child_of_node(cm_np, child) { ret = thermal_of_for_each_cooling_device(tz_np, child, tz, cdev, action); - if (ret) + if (ret) { + of_node_put(child); break; + } } of_node_put(cm_np); -- 2.40.1