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 71F38C05027 for ; Sun, 12 Feb 2023 15:29:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229695AbjBLP3V (ORCPT ); Sun, 12 Feb 2023 10:29:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229520AbjBLP3T (ORCPT ); Sun, 12 Feb 2023 10:29:19 -0500 Received: from msg-4.mailo.com (msg-4.mailo.com [213.182.54.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A98CB7EE8 for ; Sun, 12 Feb 2023 07:29:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1676215756; bh=dPUMsgqR29ABs8e2run37C3ERVUnBw1c2pLvg81OOHg=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:MIME-Version: Content-Type; b=nJ8hp41yNBG92dISTJ4UvJAu82w9D03rmvyeeSeUaQ/01YBT5bBB4PfKNcO0MllPt vLA3wuYNvcqI1VW4ZBIPz21gbs0ma6P+FVLTwrUiK9lLKCvgzqyLXI8x6cCa91KupO ZD4sBVKrdyiGonDRA6vrIV2LV2wOGQ43PiYQwyuA= Received: by b-5.in.mailobj.net [192.168.90.15] with ESMTP via ip-206.mailobj.net [213.182.55.206] Sun, 12 Feb 2023 16:29:16 +0100 (CET) X-EA-Auth: H1Q8A0ov/kkUeRXY7osnEJ9nyK8Oy9KBvib/acfOppXaJMMDA5iHVdu1/+BXf7YCSNAkP/szIa4PUCCdFWuq3Q4gBz5qUEmh Date: Sun, 12 Feb 2023 20:59:13 +0530 From: Deepak R Varma To: linux-kernel@vger.kernel.org Cc: Saurabh Singh Sengar , Praveen Kumar , Deepak R Varma Subject: [PATCH] bus: arm-cci: release node before breaking child_of_node loop Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- Please note: The proposed change is compile tested only. I do not have the necessary hardware to perform additional testing. Please suggest if there is an alternate means available to further test this change. drivers/bus/arm-cci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c index b8184a903583..1f84a5528073 100644 --- a/drivers/bus/arm-cci.c +++ b/drivers/bus/arm-cci.c @@ -461,8 +461,10 @@ static int cci_probe_ports(struct device_node *np) i = nb_ace + nb_ace_lite; - if (i >= nb_cci_ports) + if (i >= nb_cci_ports) { + of_node_put(cp); break; + } if (of_property_read_string(cp, "interface-type", &match_str)) { -- 2.34.1