From nobody Fri Sep 12 08:45:52 2025 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 DC893C61DA4 for ; Sat, 11 Feb 2023 16:15:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229772AbjBKQPH (ORCPT ); Sat, 11 Feb 2023 11:15:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229679AbjBKQPG (ORCPT ); Sat, 11 Feb 2023 11:15:06 -0500 Received: from msg-2.mailo.com (msg-2.mailo.com [213.182.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0857714229 for ; Sat, 11 Feb 2023 08:15:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1676132094; bh=obYcn7IR8jiFOnVOs2E2wFw+fR1SLSLMq4/1K3z69X4=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:MIME-Version: Content-Type; b=oS34WFIbPmdtwukzDrKYA05mX11v2hcFZ1uKoT1IPvEKVUgFNWtJCDuMgLwelhGhb rFlDgh+toN3u7qNGr78AfjjpSIIOSNeFDM/tCs01lu5H1bzhhGxSDLi6lH47c07FRM WWKgFmUv+HmAl48/a4+eRe7ZpOPbPFRYH75YpAdE= Received: by b-6.in.mailobj.net [192.168.90.16] with ESMTP via ip-206.mailobj.net [213.182.55.206] Sat, 11 Feb 2023 17:14:54 +0100 (CET) X-EA-Auth: tlLZDsFUGZ7clccaOzAbomGIsQ5H42fX/+AxviRK7WQFaJZ3026U9tqRI3JQp5e5tLx1JvjfwWY7toesuDhX1LbqiIXqNVYe Date: Sat, 11 Feb 2023 21:44:47 +0530 From: Deepak R Varma To: Andrew Lunn , Sebastian Hesselbarth , Gregory Clement , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Saurabh Singh Sengar , Praveen Kumar , Deepak R Varma Subject: [PATCH] soc: dove: release node before breaking child_of_node loop Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The iterator for_each_available_child_of_node() increments the refcount of the child node it is processing. Release such a reference when the loop needs to break due to an error during its execution. Issue identified using for_each_child.cocci Coccinelle semantic patch. Signed-off-by: Deepak R Varma Reviewed-by: Andrew Lunn --- Please note: The proposed change is compile tested only. I do not have the necessary hardware to perform additional testing. Please suggest if there i= s an alternate means available to further test this change. drivers/soc/dove/pmu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/soc/dove/pmu.c b/drivers/soc/dove/pmu.c index ffc5311c0ed8..6202dbcd20a8 100644 --- a/drivers/soc/dove/pmu.c +++ b/drivers/soc/dove/pmu.c @@ -410,13 +410,16 @@ int __init dove_init_pmu(void) struct pmu_domain *domain; =20 domain =3D kzalloc(sizeof(*domain), GFP_KERNEL); - if (!domain) + if (!domain) { + of_node_put(np); break; + } =20 domain->pmu =3D pmu; domain->base.name =3D kasprintf(GFP_KERNEL, "%pOFn", np); if (!domain->base.name) { kfree(domain); + of_node_put(np); break; } =20 --=20 2.34.1