base/node.c: initialize the accessor list before registering
authorGregory Price <gourry.memverge@gmail.com>
Mon, 30 Oct 2023 04:42:39 +0000 (00:42 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jan 2024 23:35:51 +0000 (15:35 -0800)
commita5e1c3fe5764f6457c32ead143996a77071e0f07
treee3da65e1721edc67396555cc04de4e346cdbee68
parentac95df46de7feb308bb19c6714f93f50e091221e
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>
drivers/base/node.c