
From: Martin Schwidefsky <schwidefsky@de.ibm.com>

Just found an small bug in pgalloc for s390*.  Comparing notes with other
architectures I found that pte_alloc_one is sick for alpha and sparc64 as
well.


---

 25-akpm/include/asm-alpha/pgalloc.h   |    5 ++++-
 25-akpm/include/asm-s390/pgalloc.h    |    5 ++++-
 25-akpm/include/asm-sparc64/pgalloc.h |   10 +++++++++-
 3 files changed, 17 insertions(+), 3 deletions(-)

diff -puN include/asm-alpha/pgalloc.h~pte_alloc_one-null-pointer-check include/asm-alpha/pgalloc.h
--- 25/include/asm-alpha/pgalloc.h~pte_alloc_one-null-pointer-check	Wed Apr  7 09:43:54 2004
+++ 25-akpm/include/asm-alpha/pgalloc.h	Wed Apr  7 09:43:54 2004
@@ -63,7 +63,10 @@ pte_free_kernel(pte_t *pte)
 static inline struct page *
 pte_alloc_one(struct mm_struct *mm, unsigned long addr)
 {
-	return virt_to_page(pte_alloc_one_kernel(mm, addr));
+	pte_t *pte = pte_alloc_one_kernel(mm, addr);
+	if (pte)
+		return virt_to_page(pte);
+	return 0;
 }
 
 static inline void
diff -puN include/asm-s390/pgalloc.h~pte_alloc_one-null-pointer-check include/asm-s390/pgalloc.h
--- 25/include/asm-s390/pgalloc.h~pte_alloc_one-null-pointer-check	Wed Apr  7 09:43:54 2004
+++ 25-akpm/include/asm-s390/pgalloc.h	Wed Apr  7 09:44:12 2004
@@ -139,7 +139,10 @@ pte_alloc_one_kernel(struct mm_struct *m
 static inline struct page *
 pte_alloc_one(struct mm_struct *mm, unsigned long vmaddr)
 {
-	return virt_to_page(pte_alloc_one_kernel(mm, vmaddr));
+	pte_t *pte = pte_alloc_one_kernel(mm, vmaddr);
+	if (pte)
+		return virt_to_page(pte);
+	return 0;
 }
 
 static inline void pte_free_kernel(pte_t *pte)
diff -puN include/asm-sparc64/pgalloc.h~pte_alloc_one-null-pointer-check include/asm-sparc64/pgalloc.h
--- 25/include/asm-sparc64/pgalloc.h~pte_alloc_one-null-pointer-check	Wed Apr  7 09:43:54 2004
+++ 25-akpm/include/asm-sparc64/pgalloc.h	Wed Apr  7 09:43:54 2004
@@ -189,7 +189,15 @@ static __inline__ void free_pmd_slow(pmd
 	pmd_populate_kernel(MM,PMD,page_address(PTE_PAGE))
 
 extern pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address);
-#define pte_alloc_one(MM,ADDR)	virt_to_page(pte_alloc_one_kernel(MM,ADDR))
+
+static inline struct page *
+pte_alloc_one(struct mm_struct *mm, unsigned long addr)
+{
+	pte_t *pte = pte_alloc_one_kernel(mm, addr);
+	if (pte)
+		return virt_to_page(pte);
+	return 0;
+}
 
 static __inline__ pte_t *pte_alloc_one_fast(struct mm_struct *mm, unsigned long address)
 {

_
