[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220318111709.60311-11-linmiaohe@huawei.com>
Date: Fri, 18 Mar 2022 19:17:08 +0800
From: Miaohe Lin <linmiaohe@...wei.com>
To: <akpm@...ux-foundation.org>
CC: <ziy@...dia.com>, <baolin.wang@...ux.alibaba.com>,
<ying.huang@...el.com>, <songmuchun@...edance.com>,
<apopple@...dia.com>, <linux-mm@...ck.org>,
<linux-kernel@...r.kernel.org>, <linmiaohe@...wei.com>
Subject: [PATCH v2 10/11] mm/migration: fix potential invalid node access for reclaim-based migration
If we failed to setup hotplug state callbacks for mm/demotion:online in
some corner cases, node_demotion will be left uninitialized. Invalid node
might be returned from the next_demotion_node() when doing reclaim-based
migration. Use kcalloc to allocate node_demotion to fix the issue.
Fixes: ac16ec835314 ("mm: migrate: support multiple target nodes demotion")
Signed-off-by: Miaohe Lin <linmiaohe@...wei.com>
Reviewed-by: "Huang, Ying" <ying.huang@...el.com>
---
mm/migrate.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/mm/migrate.c b/mm/migrate.c
index 97dfd1f4870d..dbd91fbdb127 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -2534,9 +2534,9 @@ static int __init migrate_on_reclaim_init(void)
{
int ret;
- node_demotion = kmalloc_array(nr_node_ids,
- sizeof(struct demotion_nodes),
- GFP_KERNEL);
+ node_demotion = kcalloc(nr_node_ids,
+ sizeof(struct demotion_nodes),
+ GFP_KERNEL);
WARN_ON(!node_demotion);
ret = cpuhp_setup_state_nocalls(CPUHP_MM_DEMOTION_DEAD, "mm/demotion:offline",
--
2.23.0
Powered by blists - more mailing lists