From: Xishi Qiu <qiuxishi@huawei.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
<jiang.liu@linux.intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>, Xishi Qiu <qiuxishi@huawei.com>
Subject: [PATCH] numa: fix NULL pointer access and memory leak in unregister_one_node()
Date: Thu, 6 Mar 2014 17:18:21 +0800 [thread overview]
Message-ID: <53183D5D.4020000@huawei.com> (raw)
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 <qiuxishi@huawei.com>
---
drivers/base/node.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
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;
}
--
1.7.1
reply other threads:[~2014-03-06 9:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53183D5D.4020000@huawei.com \
--to=qiuxishi@huawei.com \
--cc=gregkh@linuxfoundation.org \
--cc=jiang.liu@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox