* [PATCH] missing NULL pointer check in pte_alloc_one.
@ 2004-04-01 19:07 Martin Schwidefsky
0 siblings, 0 replies; 2+ messages in thread
From: Martin Schwidefsky @ 2004-04-01 19:07 UTC (permalink / raw)
To: linux-arch
Hi,
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. See patch below.
blue skies,
Martin.
ChangeLog:
Add NULL pointer check to pte_alloc_one for alpha, s390 and sparc64.
diffstat:
asm-alpha/pgalloc.h | 5 ++++-
asm-s390/pgalloc.h | 5 ++++-
asm-sparc64/pgalloc.h | 10 +++++++++-
3 files changed, 17 insertions(+), 3 deletions(-)
diff -urN linux-2.6/include/asm-alpha/pgalloc.h linux-2.6-pgalloc/include/asm-alpha/pgalloc.h
--- linux-2.6/include/asm-alpha/pgalloc.h Thu Mar 11 03:55:20 2004
+++ linux-2.6-pgalloc/include/asm-alpha/pgalloc.h Thu Apr 1 20:48:54 2004
@@ -63,7 +63,10 @@
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 -urN linux-2.6/include/asm-s390/pgalloc.h linux-2.6-pgalloc/include/asm-s390/pgalloc.h
--- linux-2.6/include/asm-s390/pgalloc.h Thu Mar 11 03:55:34 2004
+++ linux-2.6-pgalloc/include/asm-s390/pgalloc.h Thu Apr 1 20:48:54 2004
@@ -139,7 +139,10 @@
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_alloc_one_kernel(mm, vmaddr));
+ return 0;
}
static inline void pte_free_kernel(pte_t *pte)
diff -urN linux-2.6/include/asm-sparc64/pgalloc.h linux-2.6-pgalloc/include/asm-sparc64/pgalloc.h
--- linux-2.6/include/asm-sparc64/pgalloc.h Thu Apr 1 15:23:23 2004
+++ linux-2.6-pgalloc/include/asm-sparc64/pgalloc.h Thu Apr 1 20:48:54 2004
@@ -189,7 +189,15 @@
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)
{
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] missing NULL pointer check in pte_alloc_one.
@ 2004-04-07 16:23 Martin Schwidefsky
0 siblings, 0 replies; 2+ messages in thread
From: Martin Schwidefsky @ 2004-04-07 16:23 UTC (permalink / raw)
To: linux-arch; +Cc: akpm
Hi Andrew,
stupid cut-copy-paste error. I fixed the problem for alpha and sparc64
but I broke s390. pte_alloc_one shouldn't allocate two pages, return one
and forget the other without freeing it...
blue skies,
Martin.
diff -urN linux-2.6/include/asm-s390/pgalloc.h linux-2.6-pgalloc/include/asm-s390/pgalloc.h
--- linux-2.6/include/asm-s390/pgalloc.h Wed Apr 7 18:17:19 2004
+++ linux-2.6-pgalloc/include/asm-s390/pgalloc.h Wed Apr 7 18:16:50 2004
@@ -141,7 +141,7 @@
{
pte_t *pte = pte_alloc_one_kernel(mm, vmaddr);
if (pte)
- return virt_to_page(pte_alloc_one_kernel(mm, vmaddr));
+ return virt_to_page(pte);
return 0;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-04-07 16:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-07 16:23 [PATCH] missing NULL pointer check in pte_alloc_one Martin Schwidefsky
-- strict thread matches above, loose matches on Subject: below --
2004-04-01 19:07 Martin Schwidefsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox