diff options
author | Gregory Price <gourry.memverge@gmail.com> | 2023-10-30 07:42:39 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-01-26 02:27:46 +0300 |
commit | 76be69716cad648239d94e8367624df6f24e3beb (patch) | |
tree | 843fb00fe7d48caf99d7bd0d5a37712a072325a3 /drivers/base | |
parent | d5ef7480d64397dc5b91fd1d19d2c4e520870cf1 (diff) | |
download | linux-76be69716cad648239d94e8367624df6f24e3beb.tar.xz |
base/node.c: initialize the accessor list before registering
[ Upstream commit 48b5928e18dc27e05cab3dc4c78cd8a15baaf1e5 ]
The current code registers the node as available in the node array
before initializing the accessor list. This makes it so that
anything which might access the accessor list as a result of
allocations will cause an undefined memory access.
In one example, an extension to access hmat data during interleave
caused this undefined access as a result of a bulk allocation
that occurs during node initialization but before the accessor
list is initialized.
Initialize the accessor list before making the node generally
available to the global system.
Fixes: 08d9dbe72b1f ("node: Link memory nodes to their compute nodes")
Signed-off-by: Gregory Price <gregory.price@memverge.com>
Link: https://lore.kernel.org/r/20231030044239.971756-1-gregory.price@memverge.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/node.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/base/node.c b/drivers/base/node.c index faf3597a96da..a4141b57b147 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -859,11 +859,15 @@ int __register_one_node(int nid) { int error; int cpu; + struct node *node; - node_devices[nid] = kzalloc(sizeof(struct node), GFP_KERNEL); - if (!node_devices[nid]) + node = kzalloc(sizeof(struct node), GFP_KERNEL); + if (!node) return -ENOMEM; + INIT_LIST_HEAD(&node->access_list); + node_devices[nid] = node; + error = register_node(node_devices[nid], nid); /* link cpu under this node */ @@ -872,7 +876,6 @@ int __register_one_node(int nid) register_cpu_under_node(cpu, nid); } - INIT_LIST_HEAD(&node_devices[nid]->access_list); node_init_caches(nid); return error; |