public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/memory_hotplug: prevent accessing by index=-1
@ 2024-06-03 11:28 Anastasia Belova
  2024-06-03 16:07 ` David Hildenbrand
  0 siblings, 1 reply; 9+ messages in thread
From: Anastasia Belova @ 2024-06-03 11:28 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: Anastasia Belova, Oscar Salvador, Andrew Morton, linux-mm,
	linux-kernel, lvc-project

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.

Fixes: e83a437faa62 ("mm/memory_hotplug: introduce "auto-movable" online policy")
Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
---
 mm/memory_hotplug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 431b1f6753c0..bb98ee8fe698 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -846,7 +846,7 @@ static bool auto_movable_can_online_movable(int nid, struct memory_group *group,
 	unsigned long kernel_early_pages, movable_pages;
 	struct auto_movable_group_stats group_stats = {};
 	struct auto_movable_stats stats = {};
-	pg_data_t *pgdat = NODE_DATA(nid);
+	pg_data_t *pgdat = (nid != NUMA_NO_NODE) ? NODE_DATA(nid) : NULL;
 	struct zone *zone;
 	int i;
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-06-07  7:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-03 11:28 [PATCH] mm/memory_hotplug: prevent accessing by index=-1 Anastasia Belova
2024-06-03 16:07 ` David Hildenbrand
2024-06-03 17:53   ` Oscar Salvador
2024-06-03 17:58     ` David Hildenbrand
2024-06-03 19:54   ` Fedor Pchelkin
2024-06-03 20:15     ` David Hildenbrand
2024-06-06  8:06       ` [PATCH v2] " Anastasia Belova
2024-06-06  8:13         ` David Hildenbrand
2024-06-07  7:34         ` Oscar Salvador

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox