Re: [PATCH] mm/vmscan: Initialize dirty to prevent uninitialized use

From: Purva Yeshi
Date: Wed Mar 26 2025 - 02:50:22 EST


On 26/03/25 02:05, Yu Zhao wrote:
On Tue, Mar 25, 2025 at 1:49 PM Purva Yeshi <purvayeshi550@xxxxxxxxx> wrote:

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.

Thanks -- this seems like false positives from Smatch, where the
problem should be fixed.

Should we make modifications to address this Smatch error, or is it safe to ignore?


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@xxxxxxxxx>