From fecf3743b824ce4eb275ed4a1d6aee9494f6a966 Mon Sep 17 00:00:00 2001 From: "Kirill A. Shutemov" Date: Thu, 14 Nov 2013 14:31:18 -0800 Subject: m32r: fix potential NULL-pointer dereference Add missing check for memory allocation fail. Signed-off-by: Kirill A. Shutemov Cc: Hirokazu Takata Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/m32r/include/asm/pgalloc.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'arch/m32r/include/asm/pgalloc.h') diff --git a/arch/m32r/include/asm/pgalloc.h b/arch/m32r/include/asm/pgalloc.h index 0fc736198979..ac4208bcc5ad 100644 --- a/arch/m32r/include/asm/pgalloc.h +++ b/arch/m32r/include/asm/pgalloc.h @@ -43,6 +43,8 @@ static __inline__ pgtable_t pte_alloc_one(struct mm_struct *mm, { struct page *pte = alloc_page(GFP_KERNEL|__GFP_ZERO); + if (!pte) + return NULL; pgtable_page_ctor(pte); return pte; } -- cgit v1.2.3 From 7251ab6b86179f195b3f4b56d57ce9dc7a725409 Mon Sep 17 00:00:00 2001 From: "Kirill A. Shutemov" Date: Thu, 14 Nov 2013 14:31:33 -0800 Subject: m32r: handle pgtable_page_ctor() fail Signed-off-by: Kirill A. Shutemov Cc: Hirokazu Takata Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/m32r/include/asm/pgalloc.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'arch/m32r/include/asm/pgalloc.h') diff --git a/arch/m32r/include/asm/pgalloc.h b/arch/m32r/include/asm/pgalloc.h index ac4208bcc5ad..2d55a064ccac 100644 --- a/arch/m32r/include/asm/pgalloc.h +++ b/arch/m32r/include/asm/pgalloc.h @@ -45,7 +45,10 @@ static __inline__ pgtable_t pte_alloc_one(struct mm_struct *mm, if (!pte) return NULL; - pgtable_page_ctor(pte); + if (!pgtable_page_ctor(pte)) { + __free_page(pte); + return NULL; + } return pte; } -- cgit v1.2.3