Skip to contentSkip to conversation

mm/mprotect.c: avoid repeated assignment in do_mprotect_pkey()

PATCH Applied Liu Song 1 participant 1 message Oct 12, 2021

Subsystems (2)
lore
Share & tools
lore

Liu Song

author
#0 lore raw

PATCH 1/1 mm/mprotect.c: avoid repeated assignment in do_mprotect_pkey()

From: Liu Song <[email protected]>

After adjustment, the repeated assignment of "prev" is avoided, and the readability of the code is improved.

---
 mm/mprotect.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
mm/mprotect.c +4 -1
index 883e2cc85cad..e552f5e0ccbd 100644
@@ -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;
Signature · 1 line
2.20.1