From nobody Wed Apr 8 14:01:18 2026 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 3790DC38A2D for ; Wed, 26 Oct 2022 19:02:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234699AbiJZTCY (ORCPT ); Wed, 26 Oct 2022 15:02:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234678AbiJZTA7 (ORCPT ); Wed, 26 Oct 2022 15:00:59 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9C43226AEF for ; Wed, 26 Oct 2022 12:00:05 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 118E223A; Wed, 26 Oct 2022 12:00:11 -0700 (PDT) Received: from pierre123.arm.com (unknown [10.57.2.137]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2F3073F792; Wed, 26 Oct 2022 12:00:02 -0700 (PDT) From: Pierre Gondois To: linux-kernel@vger.kernel.org Cc: Rob.Herring@arm.com, sudeep.holla@arm.com, Pierre Gondois , Greg Kroah-Hartman , "Rafael J. Wysocki" Subject: [PATCH] cacheinfo: Decrement refcount in cache_setup_of_node() Date: Wed, 26 Oct 2022 20:59:54 +0200 Message-Id: <20221026185954.991547-1-pierre.gondois@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Refcounts to DT nodes are only incremented in the function and never decremented. Decrease the refcounts when necessary. Signed-off-by: Pierre Gondois Reviewed-by: Sudeep Holla --- drivers/base/cacheinfo.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index 1448a329f66d..10ddb05a6e39 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c @@ -196,7 +196,7 @@ static void cache_of_set_props(struct cacheinfo *this_l= eaf, =20 static int cache_setup_of_node(unsigned int cpu) { - struct device_node *np; + struct device_node *np, *prev; struct cacheinfo *this_leaf; unsigned int index =3D 0; =20 @@ -206,19 +206,24 @@ static int cache_setup_of_node(unsigned int cpu) return -ENOENT; } =20 + prev =3D np; + while (index < cache_leaves(cpu)) { this_leaf =3D per_cpu_cacheinfo_idx(cpu, index); - if (this_leaf->level !=3D 1) + if (this_leaf->level !=3D 1) { np =3D of_find_next_cache_node(np); - else - np =3D of_node_get(np);/* cpu node itself */ - if (!np) - break; + of_node_put(prev); + prev =3D np; + if (!np) + break; + } cache_of_set_props(this_leaf, np); this_leaf->fw_token =3D np; index++; } =20 + of_node_put(np); + if (index !=3D cache_leaves(cpu)) /* not all OF nodes populated */ return -ENOENT; =20 --=20 2.25.1