Revert "sched: Remove sched_setscheduler*() EXPORTs"
[platform/kernel/linux-rpi.git] / mm / mlock.c
index 16d2ee1..0cee3f9 100644 (file)
@@ -826,18 +826,18 @@ int user_shm_lock(size_t size, struct ucounts *ucounts)
 
        locked = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
        lock_limit = rlimit(RLIMIT_MEMLOCK);
-       if (lock_limit == RLIM_INFINITY)
-               allowed = 1;
-       lock_limit >>= PAGE_SHIFT;
+       if (lock_limit != RLIM_INFINITY)
+               lock_limit >>= PAGE_SHIFT;
        spin_lock(&shmlock_user_lock);
        memlock = inc_rlimit_ucounts(ucounts, UCOUNT_RLIMIT_MEMLOCK, locked);
 
-       if (!allowed && (memlock == LONG_MAX || memlock > lock_limit) && !capable(CAP_IPC_LOCK)) {
+       if ((memlock == LONG_MAX || memlock > lock_limit) && !capable(CAP_IPC_LOCK)) {
                dec_rlimit_ucounts(ucounts, UCOUNT_RLIMIT_MEMLOCK, locked);
                goto out;
        }
        if (!get_ucounts(ucounts)) {
                dec_rlimit_ucounts(ucounts, UCOUNT_RLIMIT_MEMLOCK, locked);
+               allowed = 0;
                goto out;
        }
        allowed = 1;