From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Wed, 18 May 2005 15:39:33 -0700 (PDT) From: Linus Torvalds Subject: Re: [PATCH] prevent NULL mmap in topdown model In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-linux-mm@kvack.org Return-Path: To: Rik van Riel Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org List-ID: On Wed, 18 May 2005, Rik van Riel wrote: > > This (trivial) patch prevents the topdown allocator from allocating > mmap areas all the way down to address zero. It's not the prettiest > patch, so suggestions for improvement are welcome ;) Why not just change the "addr >= len" test into "addr > len" and be done with it? Ie something as simple as the appended.. Linus --- diff --git a/mm/mmap.c b/mm/mmap.c --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1244,7 +1244,7 @@ arch_get_unmapped_area_topdown(struct fi addr = mm->free_area_cache; /* make sure it can fit in the remaining address space */ - if (addr >= len) { + if (addr > len) { vma = find_vma(mm, addr-len); if (!vma || addr <= vma->vm_start) /* remember the address as a hint for next time */ @@ -1266,7 +1266,7 @@ arch_get_unmapped_area_topdown(struct fi /* try just below the current vma->vm_start */ addr = vma->vm_start-len; - } while (len <= vma->vm_start); + } while (len < vma->vm_start); /* * A failed mmap() very likely causes application failure, -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: aart@kvack.org