powerpc: handle pgtable_page_ctor() fail
authorKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Thu, 14 Nov 2013 22:31:38 +0000 (14:31 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 15 Nov 2013 00:32:18 +0000 (09:32 +0900)
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/powerpc/include/asm/pgalloc-64.h
arch/powerpc/mm/pgtable_32.c
arch/powerpc/mm/pgtable_64.c

index f65e27b09bd38010218b270ebcb27adb967c277b..16cb92d215d27850f3ba15a0b7417cc0d1719f13 100644 (file)
@@ -91,7 +91,10 @@ static inline pgtable_t pte_alloc_one(struct mm_struct *mm,
        if (!pte)
                return NULL;
        page = virt_to_page(pte);
-       pgtable_page_ctor(page);
+       if (!pgtable_page_ctor(page)) {
+               __free_page(page);
+               return NULL;
+       }
        return page;
 }
 
index 6c856fb8c15b01705fb6cf5ff28c0a232d85d3bd..5b9601715289c450a23e41b7ffc62d428496b8c9 100644 (file)
@@ -121,7 +121,10 @@ pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address)
        ptepage = alloc_pages(flags, 0);
        if (!ptepage)
                return NULL;
-       pgtable_page_ctor(ptepage);
+       if (!pgtable_page_ctor(ptepage)) {
+               __free_page(ptepage);
+               return NULL;
+       }
        return ptepage;
 }
 
index 536eec72c0f701584b717b86189d039442c54acb..9d95786aa80ffbdcb8601379d774fc1f158006d0 100644 (file)
@@ -378,6 +378,10 @@ static pte_t *__alloc_for_cache(struct mm_struct *mm, int kernel)
                                       __GFP_REPEAT | __GFP_ZERO);
        if (!page)
                return NULL;
+       if (!kernel && !pgtable_page_ctor(page)) {
+               __free_page(page);
+               return NULL;
+       }
 
        ret = page_address(page);
        spin_lock(&mm->page_table_lock);
@@ -392,9 +396,6 @@ static pte_t *__alloc_for_cache(struct mm_struct *mm, int kernel)
        }
        spin_unlock(&mm->page_table_lock);
 
-       if (!kernel)
-               pgtable_page_ctor(page);
-
        return (pte_t *)ret;
 }