mm: use dedicated helper to access rlimit value
authorKrzysztof Opasiak <[email protected]>
Mon, 10 Jul 2017 22:50:03 +0000 (15:50 -0700)
committerLinus Torvalds <[email protected]>
Mon, 10 Jul 2017 23:32:33 +0000 (16:32 -0700)
Use rlimit() helper instead of manually writing whole chain from current
task to rlim_cur.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Krzysztof Opasiak <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/mmap.c

index 49c56b811b03f1f7d865c62fa5c8421a7acb424a..7fa6759322d1f2aa39f9dc2c497e714a8d9566f0 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2177,7 +2177,6 @@ static int acct_stack_growth(struct vm_area_struct *vma,
                             unsigned long size, unsigned long grow)
 {
        struct mm_struct *mm = vma->vm_mm;
-       struct rlimit *rlim = current->signal->rlim;
        unsigned long new_start;
 
        /* address space limit tests */
@@ -2185,7 +2184,7 @@ static int acct_stack_growth(struct vm_area_struct *vma,
                return -ENOMEM;
 
        /* Stack limit test */
-       if (size > READ_ONCE(rlim[RLIMIT_STACK].rlim_cur))
+       if (size > rlimit(RLIMIT_STACK))
                return -ENOMEM;
 
        /* mlock limit tests */
@@ -2193,7 +2192,7 @@ static int acct_stack_growth(struct vm_area_struct *vma,
                unsigned long locked;
                unsigned long limit;
                locked = mm->locked_vm + grow;
-               limit = READ_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
+               limit = rlimit(RLIMIT_MEMLOCK);
                limit >>= PAGE_SHIFT;
                if (locked > limit && !capable(CAP_IPC_LOCK))
                        return -ENOMEM;