From: Naoya Horiguchi Date: Thu, 22 May 2014 00:42:43 +0000 (+1000) Subject: mm/pagewalk.c: move pte null check X-Git-Tag: next-20140530~2^2~385 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=9e9df4dda900317c0a431d096d1dface033ebbd9;p=karo-tx-linux.git mm/pagewalk.c: move pte null check 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 Reported-by: Sasha Levin Signed-off-by: Andrew Morton --- diff --git a/mm/pagewalk.c b/mm/pagewalk.c index a834f4deb527..b2a075ffb96e 100644 --- a/mm/pagewalk.c +++ b/mm/pagewalk.c @@ -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)