mm/vmscan: Initialize dirty to prevent uninitialized use
Subsystems (3)
PATCH 1/1 mm/vmscan: Initialize dirty to prevent uninitialized use
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.
--- mm/vmscan.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
mm/vmscan.c +3 -3
@@ -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;
Signature · 1 line
2.34.1
Quoted 11 lines · Purva Yeshi
Fix Smatch-detected error:
mm/vmscan.c:3509walk_pte_range()error: uninitialized symbol 'dirty'.mm/vmscan.c:3522walk_pte_range()error: uninitialized symbol 'dirty'.mm/vmscan.c:3600walk_pmd_range_locked()error: uninitialized symbol 'dirty'.mm/vmscan.c:3614walk_pmd_range_locked()error: uninitialized symbol 'dirty'.mm/vmscan.c:4220lru_gen_look_around()error: uninitialized symbol 'dirty'.mm/vmscan.c:4232lru_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.
Quoted 5 lines
Explicitly initialize dirty to 0 in
walk_pte_range(),walk_pmd_range_locked(), andlru_gen_look_around()inmm/vmscan.cto fix Smatch error.Signed-off-by Purva Yeshi <[email protected]>
Quoted 10 lines · Yu Zhao
Quoted 9 lines · Purva Yeshi
Fix Smatch-detected error:
mm/vmscan.c:3509walk_pte_range()error: uninitialized symbol 'dirty'.mm/vmscan.c:3522walk_pte_range()error: uninitialized symbol 'dirty'.mm/vmscan.c:3600walk_pmd_range_locked()error: uninitialized symbol 'dirty'.mm/vmscan.c:3614walk_pmd_range_locked()error: uninitialized symbol 'dirty'.mm/vmscan.c:4220lru_gen_look_around()error: uninitialized symbol 'dirty'.mm/vmscan.c:4232lru_gen_look_around()error: uninitialized symbol 'dirty'.
Quoted 5 lines
Quoted 2 lines
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?
Quoted 6 lines
Quoted 6 lines
Explicitly initialize dirty to 0 in
walk_pte_range(),walk_pmd_range_locked(), andlru_gen_look_around()inmm/vmscan.cto fix Smatch error.Signed-off-by Purva Yeshi <[email protected]>