m68k: handle pgtable_page_ctor() fail
authorKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Thu, 14 Nov 2013 22:31:34 +0000 (14:31 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 15 Nov 2013 00:32:17 +0000 (09:32 +0900)
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/m68k/include/asm/mcf_pgalloc.h
arch/m68k/include/asm/motorola_pgalloc.h
arch/m68k/include/asm/sun3_pgalloc.h

index 313f3dd23cdc955f56af3fb581aa0e398d3a0f21..f9924fbcfe42b8f279d83758e4fc987cb32da409 100644 (file)
@@ -56,6 +56,10 @@ static inline struct page *pte_alloc_one(struct mm_struct *mm,
 
        if (!page)
                return NULL;
+       if (!pgtable_page_ctor(page)) {
+               __free_page(page);
+               return NULL;
+       }
 
        pte = kmap(page);
        if (pte) {
index 2f02f264e6944dd7fd11d8d4ffe0e10244fe1f60..24bcba496c7505e94d5c45512c399e773106b029 100644 (file)
@@ -29,18 +29,22 @@ static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
 
 static inline pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address)
 {
-       struct page *page = alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, 0);
+       struct page *page;
        pte_t *pte;
 
+       page = alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, 0);
        if(!page)
                return NULL;
+       if (!pgtable_page_ctor(page)) {
+               __free_page(page);
+               return NULL;
+       }
 
        pte = kmap(page);
        __flush_page_to_ram(pte);
        flush_tlb_kernel_page(pte);
        nocache_page(pte);
        kunmap(page);
-       pgtable_page_ctor(page);
        return page;
 }
 
index 48d80d5a666f80b64d5b62e318197b1752e29733..f868506e3350b0075799a30cc0e42206e7e21212 100644 (file)
@@ -59,7 +59,10 @@ static inline pgtable_t pte_alloc_one(struct mm_struct *mm,
                return NULL;
 
        clear_highpage(page);
-       pgtable_page_ctor(page);
+       if (!pgtable_page_ctor(page)) {
+               __free_page(page);
+               return NULL;
+       }
        return page;
 
 }