From b2f3a170ae968fac6270e89ce5738685bd2e530c Mon Sep 17 00:00:00 2001 From: Bence Csokas Date: Thu, 1 Oct 2026 13:00:07 +0200 Subject: [PATCH] cache: Make cpu_cache_invalidate_memregion() error out if there are no handlers Currently, if there are no registered handlers, cpu_cache_invalidate_memregion() returns 0. Callers are expected to check cpu_cache_has_invalidate_memregion() and return -ENXIO themselves, instead of calling this function. If a caller forgets to do this, they may erroneously think the operation succeeded. This is in contrast to x86, where cpu_cache_invalidate_memregion() itself checks if the operation is supported, and returns -ENXIO if it is not. Reviewed-by: Jonathan Cameron Signed-off-by: Bence Csokas Signed-off-by: Conor Dooley --- lib/cache_maint.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cache_maint.c b/lib/cache_maint.c index 9256a9ffc34c..132d2816d6b1 100644 --- a/lib/cache_maint.c +++ b/lib/cache_maint.c @@ -59,12 +59,12 @@ static int cache_inval_done_one(struct cache_coherency_ops_inst *cci) static int cache_invalidate_memregion(phys_addr_t addr, size_t size) { - int ret; struct cache_coherency_ops_inst *cci; struct cc_inval_params params = { .addr = addr, .size = size, }; + int ret = -ENXIO; guard(rwsem_read)(&cache_ops_instance_list_lock); list_for_each_entry(cci, &cache_ops_instance_list, node) { @@ -78,7 +78,7 @@ static int cache_invalidate_memregion(phys_addr_t addr, size_t size) return ret; } - return 0; + return ret; } struct cache_coherency_ops_inst *