Skip to contentSkip to conversation

powerpc: fix virt_to_page() with NULL

PATCH New Akinobu Mita 1 participant 1 message May 29, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: fix virt_to_page() with NULL

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 protected]>
---
 include/asm-powerpc/pgalloc-64.h |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/asm-powerpc/pgalloc-64.h +2 -1
Index: 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)