From: Huang Shijie Date: Mon, 30 Jul 2012 21:42:30 +0000 (-0700) Subject: fork: use vma_pages() to simplify the code X-Git-Tag: v5.15~21915^2~23 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=b2412b7fa7a3816fa8633dc2ff19f1a90aabe423;p=mirror_ubuntu-kernels.git fork: use vma_pages() to simplify the code The current code can be replaced by vma_pages(). So use it to simplify the code. [akpm@linux-foundation.org: initialise `len' at its definition site] Signed-off-by: Huang Shijie Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/kernel/fork.c b/kernel/fork.c index ff1cad3b7bdc..2c1802948a38 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -391,8 +391,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm) } charge = 0; if (mpnt->vm_flags & VM_ACCOUNT) { - unsigned long len; - len = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT; + unsigned long len = vma_pages(mpnt); + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */ goto fail_nomem; charge = len;