From: Xishi Qiu <qiuxi...@huawei.com>

commit 92d585ef067da7a966d6ce78c601bd1562b62619 upstream

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 <qiuxi...@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gre...@linuxfoundation.org>
Signed-off-by: Yang Shi <yang....@windriver.com>
---
 drivers/base/node.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/base/node.c b/drivers/base/node.c
index bc9f43b..8f7ed99 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -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;
 }
 
-- 
2.0.2

-- 
_______________________________________________
linux-yocto mailing list
linux-yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/linux-yocto

Reply via email to