linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Purva Yeshi <purvayeshi550@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Purva Yeshi <purvayeshi550@gmail.com>
Subject: [PATCH] mm/vmscan: Initialize dirty to prevent uninitialized use
Date: Wed, 26 Mar 2025 01:19:20 +0530	[thread overview]
Message-ID: <20250325194920.53307-1-purvayeshi550@gmail.com> (raw)

Fix Smatch-detected error:
mm/vmscan.c:3509 walk_pte_range() error: uninitialized symbol 'dirty'.
mm/vmscan.c:3522 walk_pte_range() error: uninitialized symbol 'dirty'.
mm/vmscan.c:3600 walk_pmd_range_locked() error: uninitialized symbol 'dirty'.
mm/vmscan.c:3614 walk_pmd_range_locked() error: uninitialized symbol 'dirty'.
mm/vmscan.c:4220 lru_gen_look_around() error: uninitialized symbol 'dirty'.
mm/vmscan.c:4232 lru_gen_look_around() error: uninitialized symbol 'dirty'.

Smatch reports 'dirty' as uninitialized, leading to potential
undefined behavior.

Explicitly initialize dirty to 0 in walk_pte_range(),
walk_pmd_range_locked(), and lru_gen_look_around() in mm/vmscan.c
to fix Smatch error.

Signed-off-by: Purva Yeshi <purvayeshi550@gmail.com>
---
 mm/vmscan.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index c767d71c43d7..39c49fcd960c 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -3456,7 +3456,7 @@ static bool walk_pte_range(pmd_t *pmd, unsigned long start, unsigned long end,
 			   struct mm_walk *args)
 {
 	int i;
-	bool dirty;
+	bool dirty = 0;
 	pte_t *pte;
 	spinlock_t *ptl;
 	unsigned long addr;
@@ -3535,7 +3535,7 @@ static void walk_pmd_range_locked(pud_t *pud, unsigned long addr, struct vm_area
 				  struct mm_walk *args, unsigned long *bitmap, unsigned long *first)
 {
 	int i;
-	bool dirty;
+	bool dirty = 0;
 	pmd_t *pmd;
 	spinlock_t *ptl;
 	struct folio *last = NULL;
@@ -4147,7 +4147,7 @@ static void lru_gen_age_node(struct pglist_data *pgdat, struct scan_control *sc)
 bool lru_gen_look_around(struct page_vma_mapped_walk *pvmw)
 {
 	int i;
-	bool dirty;
+	bool dirty = 0;
 	unsigned long start;
 	unsigned long end;
 	struct lru_gen_mm_walk *walk;
-- 
2.34.1



             reply	other threads:[~2025-03-25 19:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-25 19:49 Purva Yeshi [this message]
2025-03-25 20:35 ` Yu Zhao
2025-03-26  6:48   ` Purva Yeshi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250325194920.53307-1-purvayeshi550@gmail.com \
    --to=purvayeshi550@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox