mm/vmscan: fix a bug calling wakeup_kswapd() with a wrong zone index
[linux-block.git] / mm / migrate.c
index cc9f2bcd73b492aebacab4b812a515cf7e70b92b..c27b1f8097d4a72e569ce5a06be42b93184e9db0 100644 (file)
@@ -2519,6 +2519,14 @@ static int numamigrate_isolate_folio(pg_data_t *pgdat, struct folio *folio)
                        if (managed_zone(pgdat->node_zones + z))
                                break;
                }
+
+               /*
+                * If there are no managed zones, it should not proceed
+                * further.
+                */
+               if (z < 0)
+                       return 0;
+
                wakeup_kswapd(pgdat->node_zones + z, 0,
                              folio_order(folio), ZONE_MOVABLE);
                return 0;