From patchwork Sat Feb 11 16:14:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepak R Varma X-Patchwork-Id: 55845 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1566261wrn; Sat, 11 Feb 2023 08:34:23 -0800 (PST) X-Google-Smtp-Source: AK7set+nAVWEMbeETm7fgYytzAZmR7ATNI8Bf2Nk/c9VbbVpH8rdPDWs1IleLVWM+IargOcMosFO X-Received: by 2002:a50:d0c4:0:b0:4ab:1f18:7839 with SMTP id g4-20020a50d0c4000000b004ab1f187839mr10741030edf.22.1676133263071; Sat, 11 Feb 2023 08:34:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676133263; cv=none; d=google.com; s=arc-20160816; b=wCg05ShrGGpVjEXs+dpVlhKKuO6MVWzIjmURvgIYReyE99Ii9MsNdbsWiwhZ8qGziQ iuXoW5WO8Np23Je+CJel/OdxqcZqGvXxXbcO32O48h06MLgRMZqz25Azjr6kjrzewc2B N76z89mnuXXph3ywz1kP5LqxYkDz+cVeFE40q37Bp0+XgkS6iZ9hnC20P6XSpwAi8CBK AhuweafYzYcDi6+7YzN9FN8+hHzgF6aclR/nC8NaSTp4itEpphPGsT5MMagY+FXqliEH mS/nvYe9c1j/8FiI6caiA7bP3w/hiduDj8xww4qXXowIrbp4cUa3TpDZlWf9eMXp3Dj7 qA2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=PnzNF7tAL/OaGZLLmCoajchYmEeKfhmdlLwz/OV5/D8=; b=vRWyvBnu9SY051Vd5CHRjaxzliqNOjr8OxKAaY5jl+o6Brw0L0FR1fJPEPk19LP0E/ IWMZ7iY3RjUWfwUDCMgVh6Qq7OY+s1WbOQ55XMPzDLYLiIG687z030Ffu8R7cNlHQqJ8 GckCLQPejQgI5l5XYslanUQJCdW2eUQNLUdkD6n3l6wbX85yoIsmVgpjhXwUieItzWcz SCIhXaF7dlEHV+HRiyx2Q1MIxZI7OUeCIV+Zycq4zWhUQirTQFOoTq4HYrC73PG8zHKZ Ge7FYmXfSDGVtNu1ArL4LDDC1wjmTWQ5RnEtsogB/p1ibl6PsfgFGoWvk5CpTRZY0PiO hBnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=oS34WFIb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o8-20020aa7c7c8000000b004a0db601db8si8916269eds.619.2023.02.11.08.33.58; Sat, 11 Feb 2023 08:34:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=oS34WFIb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229761AbjBKQPH (ORCPT + 99 others); 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757553112652407828?= X-GMAIL-MSGID: =?utf-8?q?1757553112652407828?= 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 is 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; domain = kzalloc(sizeof(*domain), GFP_KERNEL); - if (!domain) + if (!domain) { + of_node_put(np); break; + } domain->pmu = pmu; domain->base.name = kasprintf(GFP_KERNEL, "%pOFn", np); if (!domain->base.name) { kfree(domain); + of_node_put(np); break; }