linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/mlock: set the correct prev on failure
@ 2024-10-27  2:56 Wei Yang
  2024-10-27 11:41 ` Lorenzo Stoakes
  0 siblings, 1 reply; 6+ messages in thread
From: Wei Yang @ 2024-10-27  2:56 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, Wei Yang, Lorenzo Stoakes

After commit 94d7d9233951 ("mm: abstract the vma_merge()/split_vma()
pattern for mprotect() et al."), if vma_modify_flags() return error, the
vma is set to an error code. This will lead to an invalid prev be
returned.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
CC: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
---
 mm/mlock.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/mm/mlock.c b/mm/mlock.c
index e3e3dc2b2956..8c3f9cf8f960 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -478,11 +478,12 @@ static int mlock_fixup(struct vma_iterator *vmi, struct vm_area_struct *vma,
 		/* don't set VM_LOCKED or VM_LOCKONFAULT and don't count */
 		goto out;
 
-	vma = vma_modify_flags(vmi, *prev, vma, start, end, newflags);
-	if (IS_ERR(vma)) {
-		ret = PTR_ERR(vma);
+	*prev = vma_modify_flags(vmi, *prev, vma, start, end, newflags);
+	if (IS_ERR(*prev)) {
+		ret = PTR_ERR(*prev);
 		goto out;
 	}
+	vma = *prev;
 
 	/*
 	 * Keep track of amount of locked VM.
-- 
2.34.1



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-10-29  1:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-27  2:56 [PATCH] mm/mlock: set the correct prev on failure Wei Yang
2024-10-27 11:41 ` Lorenzo Stoakes
2024-10-27 12:15   ` Wei Yang
2024-10-27 12:38   ` Wei Yang
2024-10-28 15:07   ` Liam R. Howlett
2024-10-29  1:23     ` Wei Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox