blob: d67d6f514845eec72b0a59c11007c7e63d9ccad2 [file] [log] [blame]
From: Hugh Dickins <hughd@google.com>
Subject: mm,thp,rmap: subpages_mapcount of PTE-mapped subpages: fix
Date: Fri, 18 Nov 2022 17:35:05 -0800 (PST)
Yu Zhao reports compiler warning in page_add_anon_rmap():
mm/rmap.c:1236:13: warning: variable 'first' is used uninitialized
whenever 'if' condition is false [-Wsometimes-uninitialized]
} else if (PageTransHuge(page)) {
^~~~~~~~~~~~~~~~~~~
mm/rmap.c:1248:18: note: uninitialized use occurs here
VM_BUG_ON_PAGE(!first && (flags & RMAP_EXCLUSIVE), page);
^~~~~
We do need to fix that, even though it's only uninitialized in an
impossible condition: I've chosen to initialize "first" true, to
minimize the BUGs it might then hit; but you could just as well
choose to initialize it false, to maximize the BUGs it might hit.
Link: https://lkml.kernel.org/r/7a4f5e5e-de33-dace-c526-4a3d3cf5f6e0@google.com
Signed-off-by: Hugh Dickins <hughd@google.com>
Reported-by: Yu Zhao <yuzhao@google.com>
Cc: "Kirill A. Shutemov" <kirill@shutemov.name>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/rmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/mm/rmap.c~mmthprmap-subpages_mapcount-of-pte-mapped-subpages-fix
+++ a/mm/rmap.c
@@ -1281,7 +1281,7 @@ void page_add_anon_rmap(struct page *pag
struct compound_mapcounts mapcounts;
int nr = 0, nr_pmdmapped = 0;
bool compound = flags & RMAP_COMPOUND;
- bool first;
+ bool first = true;
if (unlikely(PageKsm(page)))
lock_page_memcg(page);
_