* [PATCH] mm/mprotect.c: avoid repeated assignment in do_mprotect_pkey()
@ 2021-10-12 15:24 Liu Song
0 siblings, 0 replies; only message in thread
From: Liu Song @ 2021-10-12 15:24 UTC (permalink / raw)
To: akpm; +Cc: linux-mm, linux-kernel, liu.song11
From: Liu Song <liu.song11@zte.com.cn>
After adjustment, the repeated assignment of "prev" is avoided,
and the readability of the code is improved.
Signed-off-by: Liu Song <liu.song11@zte.com.cn>
---
mm/mprotect.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/mm/mprotect.c b/mm/mprotect.c
index 883e2cc85cad..e552f5e0ccbd 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -563,7 +563,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
error = -ENOMEM;
if (!vma)
goto out;
- prev = vma->vm_prev;
+
if (unlikely(grows & PROT_GROWSDOWN)) {
if (vma->vm_start >= end)
goto out;
@@ -581,8 +581,11 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
goto out;
}
}
+
if (start > vma->vm_start)
prev = vma;
+ else
+ prev = vma->vm_prev;
for (nstart = start ; ; ) {
unsigned long mask_off_old_flags;
--
2.20.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-10-12 15:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-12 15:24 [PATCH] mm/mprotect.c: avoid repeated assignment in do_mprotect_pkey() Liu Song
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox