Skip to content

Commit

Permalink
cacheinfo: Return error code in init_of_cache_level()
Browse files Browse the repository at this point in the history
Make init_of_cache_level() return an error code when the cache
information parsing fails to help detecting missing information.

init_of_cache_level() is only called for riscv. Returning an error
code instead of 0 will prevent detect_cache_attributes() to allocate
memory if an incomplete DT is parsed.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Link: https://lore.kernel.org/r/20230104183033.755668-3-pierre.gondois@arm.com
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
  • Loading branch information
Pierre Gondois authored and Sudeep Holla committed Jan 17, 2023
1 parent c3719bd commit 8844c3d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions drivers/base/cacheinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,11 @@ int init_of_cache_level(unsigned int cpu)
of_node_put(prev);
prev = np;
if (!of_device_is_compatible(np, "cache"))
break;
goto err_out;
if (of_property_read_u32(np, "cache-level", &level))
break;
goto err_out;
if (level <= levels)
break;
goto err_out;
if (of_property_read_bool(np, "cache-size"))
++leaves;
if (of_property_read_bool(np, "i-cache-size"))
Expand All @@ -270,6 +270,10 @@ int init_of_cache_level(unsigned int cpu)
this_cpu_ci->num_leaves = leaves;

return 0;

err_out:
of_node_put(np);
return -EINVAL;
}

#else
Expand Down

0 comments on commit 8844c3d

Please sign in to comment.