Linus Torvalds: Create helper for mmap_sem write-lock check in do_brk()

Linux Kernel Mailing List <[email protected]>
Newsgroups gmane.linux.kernel.commits.2-4
Message-ID <[email protected]>
ChangeSet 1.1575, 2005/01/12 11:17:44-02:00, [email protected]

	Linus Torvalds: Create helper for mmap_sem write-lock check in do_brk()



 mmap.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletion(-)


diff -Nru a/mm/mmap.c b/mm/mmap.c
--- a/mm/mmap.c	2005-01-13 05:05:12 -08:00
+++ b/mm/mmap.c	2005-01-13 05:05:12 -08:00
@@ -1031,6 +1031,15 @@
 	return ret;
 }
 
+
+static inline void verify_mmap_write_lock_held(struct mm_struct *mm)
+{
+	if (down_read_trylock(&mm->mmap_sem)) {
+		WARN_ON(1);
+		up_read(&mm->mmap_sem);
+	}
+}
+
 /*
  *  this is really a simplified "do_mmap".  it only handles
  *  anonymous maps.  eventually we may be able to do some
@@ -1064,7 +1073,7 @@
 	 * mm->mmap_sem is required to protect against another thread
 	 * changing the mappings while we sleep (on kmalloc for one).
 	 */
-	WARN_ON(down_read_trylock(&mm->mmap_sem));
+	verify_mmap_write_lock_held(&mm);
 
 	/*
 	 * Clear old maps.  this also does some error checking for us
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.