aboutsummaryrefslogtreecommitdiffstats
path: root/mm/secretmem.c
diff options
context:
space:
mode:
authorLorenzo Stoakes <lstoakes@gmail.com>2023-05-22 09:24:12 +0100
committerAndrew Morton <akpm@linux-foundation.org>2023-06-09 16:25:38 -0700
commit3c54a298db4c6b38bbd5f86216ce0f5ad4596ccf (patch)
tree5b271d9b7546de6c17915cedc65018d99d8d4ebd /mm/secretmem.c
parent89207c669bbf464c81e1561d8206f120a679aaf7 (diff)
downloadlinux-3c54a298db4c6b38bbd5f86216ce0f5ad4596ccf.tar.gz
mm/mmap: refactor mlock_future_check()
In all but one instance, mlock_future_check() is treated as a boolean function despite returning an error code. In one instance, this error code is ignored and replaced with -ENOMEM. This is confusing, and the inversion of true -> failure, false -> success is not warranted. Convert the function to a bool, lightly refactor and return true if the check passes, false if not. Link: https://lkml.kernel.org/r/20230522082412.56685-1-lstoakes@gmail.com Signed-off-by: Lorenzo Stoakes <lstoakes@gmail.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: Liam Howlett <liam.howlett@oracle.com> Cc: Mike Rapoport (IBM) <rppt@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/secretmem.c')
-rw-r--r--mm/secretmem.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/mm/secretmem.c b/mm/secretmem.c
index 974b32ba8b9d4..58d2af12df4fa 100644
--- a/mm/secretmem.c
+++ b/mm/secretmem.c
@@ -125,7 +125,7 @@ static int secretmem_mmap(struct file *file, struct vm_area_struct *vma)
if ((vma->vm_flags & (VM_SHARED | VM_MAYSHARE)) == 0)
return -EINVAL;
- if (mlock_future_check(vma->vm_mm, vma->vm_flags | VM_LOCKED, len))
+ if (!mlock_future_check(vma->vm_mm, vma->vm_flags | VM_LOCKED, len))
return -EAGAIN;
vm_flags_set(vma, VM_LOCKED | VM_DONTDUMP);