drivers/base/node: handle error properly in register_one_node()

If register_node() returns an error, it is not handled correctly.
The function will proceed further and try to register CPUs under the
node, which is not correct.

So, in this patch, if register_node() returns an error, we return
immediately from the function.

Link: https://lkml.kernel.org/r/[email protected]
Fixes: 76b67ed9dc ("[PATCH] node hotplug: register cpu: remove node struct")
Signed-off-by: Donet Tom <[email protected]>
Acked-by: David Hildenbrand <[email protected]>
Cc: Alison Schofield <[email protected]>
Cc: Danilo Krummrich <[email protected]>
Cc: Dave Jiang <[email protected]>
Cc: Donet Tom <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Hiroyouki Kamezawa <[email protected]>
Cc: Joanthan Cameron <[email protected]>
Cc: Oscar Salvador <[email protected]>
Cc: "Ritesh Harjani (IBM)" <[email protected]>
Cc: Yury Norov (NVIDIA) <[email protected]>
Cc: Zi Yan <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
This commit is contained in:
Donet Tom authored and Andrew Morton committed 2025-09-13 16:55:17 -07:00
1 parent 3615e106e0
commit 786eb990cf
1 file changed
+5
+5
View File
@@ -885,6 +885,11 @@ int register_one_node(int nid)
node_devices[nid] = node;
error = register_node(node_devices[nid], nid);
if (error) {
node_devices[nid] = NULL;
kfree(node);
return error;
}
/* link cpu under this node */
for_each_present_cpu(cpu) {