Subject: [PATCH] powerpc: fix virt_to_page() with NULL

From: Akinobu Mita <[email-masked]>
Date: Tue, 29 May 2007 19:46:51 +0900

pte_alloc_one() is expected to return NULL if out of memory.
But it returns virt_to_page(NULL) and it is not NULL.

Cc: Paul Mackerras <[email-masked]>
Signed-off-by: Akinobu Mita <[email-masked]>

---
 include/asm-powerpc/pgalloc-64.h |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: 2.6-rc-ps3/include/asm-powerpc/pgalloc-64.h
===================================================================
--- 2.6-rc-ps3.orig/include/asm-powerpc/pgalloc-64.h
+++ 2.6-rc-ps3/include/asm-powerpc/pgalloc-64.h
@@ -90,7 +90,8 @@ static inline pte_t *pte_alloc_one_kerne
 static inline struct page *pte_alloc_one(struct mm_struct *mm,
 					 unsigned long address)
 {
-	return virt_to_page(pte_alloc_one_kernel(mm, address));
+	pte_t *pte = pte_alloc_one_kernel(mm, address);
+	return pte ? virt_to_page(pte) : NULL;
 }
 
 static inline void pte_free_kernel(pte_t *pte)