mm/page_alloc.c: initialize num_movable in move_freepages()
authorDavid Rientjes <[email protected]>
Fri, 26 Oct 2018 22:09:24 +0000 (15:09 -0700)
committerLinus Torvalds <[email protected]>
Fri, 26 Oct 2018 23:26:35 +0000 (16:26 -0700)
If move_freepages_block() returns 0 because !zone_spans_pfn(),
*num_movable can hold the value from the stack because it does not get
initialized in move_freepages().

Move the initialization to move_freepages_block() to guarantee the value
actually makes sense.

This currently doesn't affect its only caller where num_movable != NULL,
so no bug fix, but just more robust.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: David Rientjes <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Acked-by: Vlastimil Babka <[email protected]>
Cc: Greg Thelen <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/page_alloc.c

index d73ff2188d72d4cf5c31510c0688c17f337181f8..bdb7eb25acf8f05f66643e6869135071122edb07 100644 (file)
@@ -2021,10 +2021,6 @@ static int move_freepages(struct zone *zone,
                  pfn_valid(page_to_pfn(end_page)) &&
                  page_zone(start_page) != page_zone(end_page));
 #endif
-
-       if (num_movable)
-               *num_movable = 0;
-
        for (page = start_page; page <= end_page;) {
                if (!pfn_valid_within(page_to_pfn(page))) {
                        page++;
@@ -2064,6 +2060,9 @@ int move_freepages_block(struct zone *zone, struct page *page,
        unsigned long start_pfn, end_pfn;
        struct page *start_page, *end_page;
 
+       if (num_movable)
+               *num_movable = 0;
+
        start_pfn = page_to_pfn(page);
        start_pfn = start_pfn & ~(pageblock_nr_pages-1);
        start_page = pfn_to_page(start_pfn);