summaryrefslogtreecommitdiff
path: root/drivers/base/cacheinfo.c
diff options
context:
space:
mode:
authorPierre Gondois <pierre.gondois@arm.com>2023-01-04 19:30:25 +0100
committerSudeep Holla <sudeep.holla@arm.com>2023-01-17 22:00:06 +0000
commit8844c3df001bc1d8397fddea341308da63855d53 (patch)
tree59363df47a7aa67a555cd76c0649e4897723a8ce /drivers/base/cacheinfo.c
parentc3719bd9eeb2edf84bd263d662e36ca0ba262a23 (diff)
cacheinfo: Return error code in init_of_cache_level()
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>
Diffstat (limited to 'drivers/base/cacheinfo.c')
-rw-r--r--drivers/base/cacheinfo.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c
index b60788aacfef..0a96d0b9338a 100644
--- a/drivers/base/cacheinfo.c
+++ b/drivers/base/cacheinfo.c
@@ -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"))
@@ -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