powerpc/mm: bail out early when flushing TLB page
authorArseny Solokha <asolokha@kb.kras.ru>
Fri, 30 Jan 2015 12:08:27 +0000 (19:08 +0700)
committerScott Wood <scottwood@freescale.com>
Sat, 31 Jan 2015 00:39:00 +0000 (18:39 -0600)
MMU_NO_CONTEXT is conditionally defined as 0 or (unsigned int)-1. However,
in __flush_tlb_page() a corresponding variable is only tested for open
coded 0, which can cause NULL pointer dereference if `mm' argument was
legitimately passed as such.

Bail out early in case the first argument is NULL, thus eliminate confusion
between different values of MMU_NO_CONTEXT and avoid disabling and then
re-enabling preemption unnecessarily.

Signed-off-by: Arseny Solokha <asolokha@kb.kras.ru>
Signed-off-by: Scott Wood <scottwood@freescale.com>
arch/powerpc/mm/tlb_nohash.c

index f38ea4df6a8556f5f84f50ab1a37798624036b4f..ab0616b0e6c24eb83732e94ba0b4b23823038031 100644 (file)
@@ -284,8 +284,11 @@ void __flush_tlb_page(struct mm_struct *mm, unsigned long vmaddr,
        struct cpumask *cpu_mask;
        unsigned int pid;
 
+       if (unlikely(!mm))
+               return;
+
        preempt_disable();
-       pid = mm ? mm->context.id : 0;
+       pid = mm->context.id;
        if (unlikely(pid == MMU_NO_CONTEXT))
                goto bail;
        cpu_mask = mm_cpumask(mm);
This page took 0.025907 seconds and 5 git commands to generate.