[PATCH] powerpc: fix virt_to_page() with NULL

Akinobu Mita mita at fixstars.com
Tue May 29 20:46:51 EST 2007


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 <paulus at samba.org>
Signed-off-by: Akinobu Mita <mita at fixstars.com>

---
 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)



More information about the Linuxppc-dev mailing list