public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched: add sanity check in partition_sched_domains()
@ 2008-11-04  8:20 Li Zefan
  2008-11-04  9:28 ` Ingo Molnar
  0 siblings, 1 reply; 3+ messages in thread
From: Li Zefan @ 2008-11-04  8:20 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML, Peter Zijlstra

It's wrong to make dattr_new = NULL if doms_new == NULL, it introduces
memory leak if dattr_new != NULL. Fortunately dattr_new is always NULL
in this case. So remove the code and add a sanity check.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 kernel/sched.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index baa7e4b..0dcda75 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -7787,7 +7787,7 @@ match1:
 		ndoms_cur = 0;
 		doms_new = &fallback_doms;
 		cpus_andnot(doms_new[0], cpu_online_map, cpu_isolated_map);
-		dattr_new = NULL;
+		BUG_ON(dattr_new);
 	}
 
 	/* Build new domains */
-- 
1.5.4.rc3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] sched: add sanity check in partition_sched_domains()
  2008-11-04  8:20 [PATCH] sched: add sanity check in partition_sched_domains() Li Zefan
@ 2008-11-04  9:28 ` Ingo Molnar
  2008-11-04 10:06   ` Li Zefan
  0 siblings, 1 reply; 3+ messages in thread
From: Ingo Molnar @ 2008-11-04  9:28 UTC (permalink / raw)
  To: Li Zefan; +Cc: LKML, Peter Zijlstra


* Li Zefan <lizf@cn.fujitsu.com> wrote:

> It's wrong to make dattr_new = NULL if doms_new == NULL, it introduces
> memory leak if dattr_new != NULL. Fortunately dattr_new is always NULL
> in this case. So remove the code and add a sanity check.
> 
> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
> ---
>  kernel/sched.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

applied to tip/sched/core, thanks!

a small detail, i changed this:

> +		BUG_ON(dattr_new);

to WARN_ON_ONCE().

If there's a rare setup-time memory leak we dont want to crash the box 
via a BUG_ON(), as that only results in unhappy users. We want a 
WARN_ON_ONCE() so that we get nice bugreports and kerneloops.org 
coverage as well instead.

We use BUG_ON() in new code only in the rarest of circumstances: if we 
absolutely want to bring down the box right there - because there's a 
serious risk of data corruption, security breach, etc.

	Ingo

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] sched: add sanity check in partition_sched_domains()
  2008-11-04  9:28 ` Ingo Molnar
@ 2008-11-04 10:06   ` Li Zefan
  0 siblings, 0 replies; 3+ messages in thread
From: Li Zefan @ 2008-11-04 10:06 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML, Peter Zijlstra

> a small detail, i changed this:
> 
>> +		BUG_ON(dattr_new);
> 
> to WARN_ON_ONCE().
> 
> If there's a rare setup-time memory leak we dont want to crash the box 
> via a BUG_ON(), as that only results in unhappy users. We want a 
> WARN_ON_ONCE() so that we get nice bugreports and kerneloops.org 
> coverage as well instead.
> 
> We use BUG_ON() in new code only in the rarest of circumstances: if we 
> absolutely want to bring down the box right there - because there's a 
> serious risk of data corruption, security breach, etc.
> 

I see the point, thx for the explanation. :)


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-11-04 10:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-04  8:20 [PATCH] sched: add sanity check in partition_sched_domains() Li Zefan
2008-11-04  9:28 ` Ingo Molnar
2008-11-04 10:06   ` Li Zefan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox