ARM: cache: do not crash when the MMU isn't yet setup
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@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
5611ccb042
commit
0fdd91d92b
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue