Skip to content

Commit 5958d35

Browse files
Anastasia Belovaakpm00
authored andcommitted
mm/memory_hotplug: prevent accessing by index=-1
nid may be equal to NUMA_NO_NODE=-1. Prevent accessing node_data array by invalid index with check for nid. Found by Linux Verification Center (linuxtesting.org) with SVACE. Link: https://lkml.kernel.org/r/[email protected] Fixes: e83a437 ("mm/memory_hotplug: introduce "auto-movable" online policy") Signed-off-by: Anastasia Belova <[email protected]> Acked-by: David Hildenbrand <[email protected]> Acked-by: Oscar Salvador <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent f742829 commit 5958d35

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mm/memory_hotplug.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,6 @@ static bool auto_movable_can_online_movable(int nid, struct memory_group *group,
846846
unsigned long kernel_early_pages, movable_pages;
847847
struct auto_movable_group_stats group_stats = {};
848848
struct auto_movable_stats stats = {};
849-
pg_data_t *pgdat = NODE_DATA(nid);
850849
struct zone *zone;
851850
int i;
852851

@@ -857,6 +856,8 @@ static bool auto_movable_can_online_movable(int nid, struct memory_group *group,
857856
auto_movable_stats_account_zone(&stats, zone);
858857
} else {
859858
for (i = 0; i < MAX_NR_ZONES; i++) {
859+
pg_data_t *pgdat = NODE_DATA(nid);
860+
860861
zone = pgdat->node_zones + i;
861862
if (populated_zone(zone))
862863
auto_movable_stats_account_zone(&stats, zone);

0 commit comments

Comments
 (0)