linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] mm/madvise: initialize prev pointer in madvise_walk_vmas
@ 2025-06-17  2:05 Lance Yang
  2025-06-17  2:24 ` Barry Song
                   ` (3 more replies)
  0 siblings, 4 replies; 19+ messages in thread
From: Lance Yang @ 2025-06-17  2:05 UTC (permalink / raw)
  To: akpm
  Cc: 21cnbao, david, Liam.Howlett, vbabka, jannh, lorenzo.stoakes,
	linux-kernel, linux-mm, Lance Yang

From: Lance Yang <lance.yang@linux.dev>

The prev pointer was uninitialized, which could lead to undefined behavior
where its address is taken and passed to the visit() callback without being
assigned a value.

Initializing it to NULL makes the code safer and prevents potential bugs
if a future callback function attempts to read from it.

Signed-off-by: Lance Yang <lance.yang@linux.dev>
---
 mm/madvise.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/madvise.c b/mm/madvise.c
index 267d8e4adf31..c87325000303 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -1536,10 +1536,10 @@ int madvise_walk_vmas(struct mm_struct *mm, unsigned long start,
 				   struct vm_area_struct **prev, unsigned long start,
 				   unsigned long end, void *arg))
 {
+	struct vm_area_struct *prev = NULL;
 	struct vm_area_struct *vma;
-	struct vm_area_struct *prev;
-	unsigned long tmp;
 	int unmapped_error = 0;
+	unsigned long tmp;
 	int error;
 
 	/*
-- 
2.49.0



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

end of thread, other threads:[~2025-06-17  9:27 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-17  2:05 [PATCH 1/1] mm/madvise: initialize prev pointer in madvise_walk_vmas Lance Yang
2025-06-17  2:24 ` Barry Song
2025-06-17  4:57   ` Lance Yang
2025-06-17  5:19     ` Barry Song
2025-06-17  6:03       ` Lance Yang
2025-06-17  7:54 ` David Hildenbrand
2025-06-17  8:18   ` Lance Yang
2025-06-17  8:21   ` Lorenzo Stoakes
2025-06-17  8:28     ` David Hildenbrand
2025-06-17  8:34       ` Lorenzo Stoakes
2025-06-17  8:38         ` David Hildenbrand
2025-06-17  8:50           ` Lorenzo Stoakes
2025-06-17  8:53             ` David Hildenbrand
2025-06-17  8:43   ` Lorenzo Stoakes
2025-06-17  8:51     ` Lorenzo Stoakes
2025-06-17  8:26 ` Lorenzo Stoakes
2025-06-17  8:50 ` Lorenzo Stoakes
2025-06-17  9:21   ` Lance Yang
2025-06-17  9:26     ` Lorenzo Stoakes

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