Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1201833rwi; Wed, 26 Oct 2022 12:03:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5HFcW3q4hAJss541xDwY51PmH033hTI6uNyYjjlbLOesSORV+sK+To0PNKe6Dat/0DZyrd X-Received: by 2002:a17:90b:4f45:b0:20d:3282:e5e0 with SMTP id pj5-20020a17090b4f4500b0020d3282e5e0mr5882540pjb.8.1666811008718; Wed, 26 Oct 2022 12:03:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666811008; cv=none; d=google.com; s=arc-20160816; b=hgV9t43FZtidZpQ2RScG6V1+2o3WfcrPqPTqd4BEhQIXVb9sWZQ3gSPZqL3ux4yUNB KjJDj+LbfFijqrWuabcsvXf8d9EqG3ubxOQvR2mYsXPfr88dKk2DfKheM+cMYUMyR4I/ vrtFAQMNp+7m4mYXdcrsyickzS6vubYu4yLOatidK64FlTgME39Syh2VGwgGzKgfUIQa lam9kOp5ymSRT1oUeFHLRbNA+YDRq9XdzbYQzLcm2M1RpwhJ4x35qmBJN1fXwnk/6j9l sqvND9iGTlfClyi9u6Er2rojn64J8D3o3Xwd3J14MwsXmBOhZTqPrRy0eWOP8LpS8RzL f6zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=9cOkhfL+bV+e8m2etM0HOfk8nawWJUaGuXm8XWIejFc=; b=IXFfXFgdxpK2vuvhs7LM1FaDhpXbVoYYiFkIL60iEngnqIxOcT755j+c6siVH1L/q4 g8VFdFB2Pzu6Le7kXe5DQg+2sGtE9Q9ajiMUGfLuBq7fP8rwjtsrF/57lbtjKjMHgJ14 ccpADwB1pz9g8HvhhGTTd4rnDkBrBP/Z04pwgb0NQEJbZdnuGFTnefs7i4RA/gc226fh gmImBTlo1UdqSQxhZTVTPS+mW2OsfzeBqAxAzgjApx9C/n1JZcTU0JtRNUS/+lq91RfG tzaCvkiQlFSLDzvVB//cn8EQd+QZpYTL+i5jgbFUPiJF5XOXPJTUrk4NwRwj1qXu9KZj YtxQ== ARC-Authentication-Results: i=1; mx.google.com; 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=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e15-20020a656bcf000000b0043966935b33si7214252pgw.166.2022.10.26.12.03.16; Wed, 26 Oct 2022 12:03:28 -0700 (PDT) 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; 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=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234583AbiJZTCX (ORCPT + 99 others); Wed, 26 Oct 2022 15:02:23 -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: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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 Refcounts to DT nodes are only incremented in the function and never decremented. Decrease the refcounts when necessary. Signed-off-by: Pierre Gondois --- 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_leaf, 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 = 0; @@ -206,19 +206,24 @@ static int cache_setup_of_node(unsigned int cpu) return -ENOENT; } + prev = np; + while (index < cache_leaves(cpu)) { this_leaf = per_cpu_cacheinfo_idx(cpu, index); - if (this_leaf->level != 1) + if (this_leaf->level != 1) { np = of_find_next_cache_node(np); - else - np = of_node_get(np);/* cpu node itself */ - if (!np) - break; + of_node_put(prev); + prev = np; + if (!np) + break; + } cache_of_set_props(this_leaf, np); this_leaf->fw_token = np; index++; } + of_node_put(np); + if (index != cache_leaves(cpu)) /* not all OF nodes populated */ return -ENOENT; -- 2.25.1