[PATCH 02/10] ARM: cache: do not crash when the MMU isn't yet setup
Andre Heider
a.heider at gmail.com
Sat Oct 19 08:20:47 EDT 2013
Drivers currently cannot implement explicit cache handling and rely on
running the same code before and after mmu_initcall() without crashing.
Depending on the chosen config options, the cache functions are not yet
setup and using them early on ends in a null pointer dereference.
The RPi's mailbox driver is such a case; it requires cache handling once
the MMU is fully set up and yet the RPi setup needs to use the driver to
get the memory size before mem_initcall() and hence mmu_initcall().
Fix this by checking the cache_fns pointer before dereferencing it.
Signed-off-by: Andre Heider <a.heider at gmail.com>
---
arch/arm/cpu/cache.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/arch/arm/cpu/cache.c b/arch/arm/cpu/cache.c
index 7aab55b..223e308 100644
--- a/arch/arm/cpu/cache.c
+++ b/arch/arm/cpu/cache.c
@@ -41,32 +41,38 @@ DEFINE_CPU_FNS(v7)
void __dma_clean_range(unsigned long start, unsigned long end)
{
- cache_fns->dma_clean_range(start, end);
+ if (cache_fns)
+ cache_fns->dma_clean_range(start, end);
}
void __dma_flush_range(unsigned long start, unsigned long end)
{
- cache_fns->dma_flush_range(start, end);
+ if (cache_fns)
+ cache_fns->dma_flush_range(start, end);
}
void __dma_inv_range(unsigned long start, unsigned long end)
{
- cache_fns->dma_inv_range(start, end);
+ if (cache_fns)
+ cache_fns->dma_inv_range(start, end);
}
void __mmu_cache_on(void)
{
- cache_fns->mmu_cache_on();
+ if (cache_fns)
+ cache_fns->mmu_cache_on();
}
void __mmu_cache_off(void)
{
- cache_fns->mmu_cache_off();
+ if (cache_fns)
+ cache_fns->mmu_cache_off();
}
void __mmu_cache_flush(void)
{
- cache_fns->mmu_cache_flush();
+ if (cache_fns)
+ cache_fns->mmu_cache_flush();
}
int arm_set_cache_functions(void)
--
1.8.3.2
More information about the barebox
mailing list