Re: [patch 3/3] IA64: virt_to_page() can be called with NULL arg

From: Andrew Morton <akpm_at_osdl.org>
Date: 2006-12-20 21:47:54
On Wed, 20 Dec 2006 11:14:53 +0100
Jes Sorensen <jes@sgi.com> wrote:

> Kirill Korotaev wrote:
> > Jes Sorensen wrote:
> >> If you hit this, yes I'd insert the BUG_ON in your test kernel and fix
> >> the code. Maybe add the BUG_ON in upstream for CONFIG_DEBUG or
> >> something.
> > I guess then all the platforms should be analyzed/patched carefully
> > or all the callers of virt_to_page().
> > Care to create debug patch?
> 
> Well you suggested a patch which just hides the problem. I suggest you
> change it to have the BUG_ON().
> 

The patch doesn't hide any problems:

--- a/include/asm-ia64/pgalloc.h~ia64-virt_to_page-can-be-called-with-null-arg
+++ a/include/asm-ia64/pgalloc.h
@@ -137,7 +137,8 @@ pmd_populate_kernel(struct mm_struct *mm
 static inline struct page *pte_alloc_one(struct mm_struct *mm,
 					 unsigned long addr)
 {
-	return virt_to_page(pgtable_quicklist_alloc());
+	void *pg = pgtable_quicklist_alloc();
+	return pg ? virt_to_page(pg) : NULL;
 }
 


if the memory allocation function fails, we propagate that failure back to
callers.  All very good.

From a quick look it seems that the pte_alloc() callers are all nicely
handling the failures.

The patch looks good to me?
-
To unsubscribe from this list: send the line "unsubscribe linux-ia64" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Wed, 20 Dec 2006 02:47:54 -0800

This archive was generated by hypermail 2.1.8 : 2006-12-20 21:51:44 EST