Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 841e31e5 authored by Rajman Mekaco's avatar Rajman Mekaco Committed by Linus Torvalds
Browse files

mm/mmap.c: find_vma(): remove unnecessary if(mm) check

The "if (mm)" check is not required in find_vma, as the kernel code
calls find_vma only when it is absolutely sure that the mm_struct arg to
it is non-NULL.

Remove the if(mm) check and adding the a WARN_ONCE(!mm) for now.  This
will serve the purpose of mandating that the execution
context(user-mode/kernel-mode) be known before find_vma is called.  Also
fixed 2 checkpatch.pl errors in the declaration of the rb_node and
vma_tmp local variables.

I was browsing through the internet and read a discussion at
https://lkml.org/lkml/2012/3/27/342

 which discusses removal of the
validation check within find_vma.  Since no-one responded, I decided to
send this patch with Andrew's suggestions.

[akpm@linux-foundation.org: add remove-me comment]
Signed-off-by: default avatarRajman Mekaco <rajman.mekaco@gmail.com>
Cc: Kautuk Consul <consul.kautuk@gmail.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Acked-by: default avatarKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 4d67d860
Loading
Loading
Loading
Loading
+27 −26
Original line number Diff line number Diff line
@@ -1639,7 +1639,9 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
{
	struct vm_area_struct *vma = NULL;

	if (mm) {
	if (WARN_ON_ONCE(!mm))		/* Remove this in linux-3.6 */
		return NULL;

	/* Check the cache first. */
	/* (Cache hit rate is typically around 35%.) */
	vma = mm->mmap_cache;
@@ -1666,7 +1668,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
		if (vma)
			mm->mmap_cache = vma;
	}
	}
	return vma;
}