Skip to content

Commit

Permalink
of: base: Shift refcount decrement in of_find_last_cache_level()
Browse files Browse the repository at this point in the history
Currently, of_find_next_cache_node() and of_property_read_u32()
are called on objects after their refcount have been decremented.
Re-order the calls to decrement the refcount after the function
calls.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Link: https://lore.kernel.org/r/20220930144936.2882481-1-pierre.gondois@arm.com
Signed-off-by: Rob Herring <robh@kernel.org>
  • Loading branch information
Pierre Gondois authored and Rob Herring committed Oct 3, 2022
1 parent abb1bc7 commit 7a7f585
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/of/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -2088,12 +2088,13 @@ int of_find_last_cache_level(unsigned int cpu)
struct device_node *prev = NULL, *np = of_cpu_device_node_get(cpu);

while (np) {
of_node_put(prev);
prev = np;
of_node_put(np);
np = of_find_next_cache_node(np);
}

of_property_read_u32(prev, "cache-level", &cache_level);
of_node_put(prev);

return cache_level;
}
Expand Down

0 comments on commit 7a7f585

Please sign in to comment.