Skip to content

Commit 786eb99

Browse files
donettom-1akpm00
authored andcommitted
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: 76b67ed ("[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]>
1 parent 3615e10 commit 786eb99

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/base/node.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,11 @@ int register_one_node(int nid)
885885
node_devices[nid] = node;
886886

887887
error = register_node(node_devices[nid], nid);
888+
if (error) {
889+
node_devices[nid] = NULL;
890+
kfree(node);
891+
return error;
892+
}
888893

889894
/* link cpu under this node */
890895
for_each_present_cpu(cpu) {

0 commit comments

Comments
 (0)