Skip to content

Commit

Permalink
numa: fix NULL pointer access and memory leak in unregister_one_node()
Browse files Browse the repository at this point in the history
When doing socket hot remove, "node_devices[nid]" is set to NULL;
acpi_processor_remove()
	try_offline_node()
		unregister_one_node()

Then hot add a socket, but do not echo 1 > /sys/devices/system/cpu/cpuXX/online,
so register_one_node() will not be called, and "node_devices[nid]"
is still NULL.

If doing socket hot remove again, NULL pointer access will be happen.
unregister_one_node()
	unregister_node()

Another, we should free the memory used by "node_devices[nid]" in
unregister_one_node().

Signed-off-by: Xishi Qiu <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Xishi Qiu authored and gregkh committed Mar 9, 2014
1 parent aa0689b commit 92d585e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/base/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,11 @@ int register_one_node(int nid)

void unregister_one_node(int nid)
{
if (!node_devices[nid])
return;

unregister_node(node_devices[nid]);
kfree(node_devices[nid]);
node_devices[nid] = NULL;
}

Expand Down

0 comments on commit 92d585e

Please sign in to comment.