cacheinfo: Decrement refcount in cache_setup_of_node()

Refcounts to DT nodes are only incremented in the function
and never decremented. Decrease the refcounts when necessary.

Signed-off-by: Pierre Gondois <[email protected]>
Reviewed-by: Sudeep Holla <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
Pierre Gondois authored and Greg Kroah-Hartman committed 2022-11-10 18:33:28 +01:00
1 parent 189a87f8ef
commit 3da72e1837
1 file changed
+11 -6
+11 -6
View File
@@ -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;