From: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
To: Ingo Molnar <mingo@elte.hu>,
Rusty Russell <rusty@rustcorp.com.au>,
Mike Travis <travis@sgi.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH -tip/cpus4096-v2] cpumask: fix memory leak and cpumask corruption
Date: Thu, 23 Oct 2008 21:59:59 -0700 [thread overview]
Message-ID: <4901564F.7020308@ct.jp.nec.com> (raw)
From: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
On CONFIG_CPUMASK_OFFSTACK enabled kernel, when exiting
smp_call_function_many() without calling arch_send_call_function_ipi()
allbutself should be freed.
Also, the memory for allbutself shouldn't be freed when
arch_send_call_function_ipi() is called. The memory region will be
referenced in generic_smp_call_function_interrupt(). And the memory
will be freed at rcu_free_call_data().
Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
---
kernel/smp.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/kernel/smp.c b/kernel/smp.c
index da98191..96b39e3 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -88,6 +88,7 @@ static void rcu_free_call_data(struct rcu_head *head)
struct call_function_data *data;
data = container_of(head, struct call_function_data, rcu_head);
+ free_cpumask_var(data->cpumask);
kfree(data);
}
@@ -347,7 +348,7 @@ void smp_call_function_many(const struct cpumask *mask,
* into a targetted single call instead since it's faster.
*/
if (!num_cpus)
- return;
+ goto out;
else if (num_cpus == 1) {
cpu = cpumask_first(allbutself);
smp_call_function_single(cpu, func, info, wait);
@@ -382,9 +383,12 @@ void smp_call_function_many(const struct cpumask *mask,
/* optionally wait for the CPUs to complete */
if (wait) {
csd_flag_wait(&data->csd);
- if (unlikely(slowpath))
+ if (unlikely(slowpath)) {
smp_call_function_mask_quiesce_stack(allbutself);
+ free_cpumask_var(allbutself);
+ }
}
+ return;
out:
free_cpumask_var(allbutself);
}
--
1.5.6
next reply other threads:[~2008-10-24 5:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-24 4:59 Hiroshi Shimamoto [this message]
2008-10-24 8:55 ` [PATCH -tip/cpus4096-v2] cpumask: fix memory leak and cpumask corruption Rusty Russell
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=4901564F.7020308@ct.jp.nec.com \
--to=h-shimamoto@ct.jp.nec.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rusty@rustcorp.com.au \
--cc=travis@sgi.com \
/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