]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mm/pagewalk.c: move pte null check
authorNaoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Thu, 22 May 2014 00:42:43 +0000 (10:42 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 22 May 2014 00:42:43 +0000 (10:42 +1000)
huge_pte_offset() can return NULL, so we need check it before trying to
take page table lock to avoid a crash.

Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Reported-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/pagewalk.c

index a834f4deb527e809b1dba00801c5adedf88196e2..b2a075ffb96edb96497c14934b9342a0ae6a5554 100644 (file)
@@ -193,12 +193,14 @@ static int walk_hugetlb_range(unsigned long addr, unsigned long end,
        do {
                next = hugetlb_entry_end(h, addr, end);
                pte = huge_pte_offset(walk->mm, addr & hmask);
+               if (!pte)
+                       continue;
                ptl = huge_pte_lock(h, mm, pte);
                /*
                 * Callers should have their own way to handle swap entries
                 * in walk->hugetlb_entry().
                 */
-               if (pte && walk->hugetlb_entry)
+               if (walk->hugetlb_entry)
                        err = walk->hugetlb_entry(pte, addr, next, walk);
                spin_unlock(ptl);
                if (err)