2009-10-09 09:31:18

by Catalin Marinas

[permalink] [raw]
Subject: [PATCH 1/2] kmemleak: Use GFP_ATOMIC for early_alloc().

We can't use GFP_KERNEL inside rcu_read_lock().

Signed-off-by: Tetsuo Handa <[email protected]>
Signed-off-by: Catalin Marinas <[email protected]>
---
mm/kmemleak.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 4ea4510..a617518 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -833,7 +833,7 @@ static void early_alloc(struct early_log *log)
*/
rcu_read_lock();
object = create_object((unsigned long)log->ptr, log->size,
- log->min_count, GFP_KERNEL);
+ log->min_count, GFP_ATOMIC);
spin_lock_irqsave(&object->lock, flags);
for (i = 0; i < log->trace_len; i++)
object->trace[i] = log->trace[i];


2009-10-09 09:31:28

by Catalin Marinas

[permalink] [raw]
Subject: [PATCH 2/2] kmemleak: Check for NULL pointer returned by create_object()

This patch adds NULL pointer checking in the early_alloc() function.

Reported-by: Paul E. McKenney <[email protected]>
Signed-off-by: Catalin Marinas <[email protected]>
---
mm/kmemleak.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index a617518..8bf765c 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -834,11 +834,14 @@ static void early_alloc(struct early_log *log)
rcu_read_lock();
object = create_object((unsigned long)log->ptr, log->size,
log->min_count, GFP_ATOMIC);
+ if (!object)
+ goto out;
spin_lock_irqsave(&object->lock, flags);
for (i = 0; i < log->trace_len; i++)
object->trace[i] = log->trace[i];
object->trace_len = log->trace_len;
spin_unlock_irqrestore(&object->lock, flags);
+out:
rcu_read_unlock();
}

2009-10-09 09:38:24

by Catalin Marinas

[permalink] [raw]
Subject: Re: [PATCH 1/2] kmemleak: Use GFP_ATOMIC for early_alloc().

On Fri, 2009-10-09 at 10:30 +0100, Catalin Marinas wrote:
> We can't use GFP_KERNEL inside rcu_read_lock().
>
> Signed-off-by: Tetsuo Handa <[email protected]>
> Signed-off-by: Catalin Marinas <[email protected]>

I mistakenly dropped the author information. The correct patch should
have a "From: Tetsuo" line. I'll re-post in reply to this message.

--
Catalin

2009-10-09 09:40:41

by Catalin Marinas

[permalink] [raw]
Subject: [PATCH] kmemleak: Use GFP_ATOMIC for early_alloc().

From: Tetsuo Handa <[email protected]>

We can't use GFP_KERNEL inside rcu_read_lock().

Signed-off-by: Tetsuo Handa <[email protected]>
Signed-off-by: Catalin Marinas <[email protected]>
---

Please ignore [PATCH 1/2] with the same subject as it didn't have the
correct author information. Thanks.

mm/kmemleak.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 4ea4510..a617518 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -833,7 +833,7 @@ static void early_alloc(struct early_log *log)
*/
rcu_read_lock();
object = create_object((unsigned long)log->ptr, log->size,
- log->min_count, GFP_KERNEL);
+ log->min_count, GFP_ATOMIC);
spin_lock_irqsave(&object->lock, flags);
for (i = 0; i < log->trace_len; i++)
object->trace[i] = log->trace[i];

2009-10-09 12:17:07

by Pekka Enberg

[permalink] [raw]
Subject: Re: [PATCH 2/2] kmemleak: Check for NULL pointer returned by create_object()

On Fri, Oct 9, 2009 at 12:30 PM, Catalin Marinas
<[email protected]> wrote:
> This patch adds NULL pointer checking in the early_alloc() function.
>
> Reported-by: Paul E. McKenney <[email protected]>
> Signed-off-by: Catalin Marinas <[email protected]>

Acked-by: Pekka Enberg <[email protected]>

> ---
> ?mm/kmemleak.c | ? ?3 +++
> ?1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/mm/kmemleak.c b/mm/kmemleak.c
> index a617518..8bf765c 100644
> --- a/mm/kmemleak.c
> +++ b/mm/kmemleak.c
> @@ -834,11 +834,14 @@ static void early_alloc(struct early_log *log)
> ? ? ? ?rcu_read_lock();
> ? ? ? ?object = create_object((unsigned long)log->ptr, log->size,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? log->min_count, GFP_ATOMIC);
> + ? ? ? if (!object)
> + ? ? ? ? ? ? ? goto out;
> ? ? ? ?spin_lock_irqsave(&object->lock, flags);
> ? ? ? ?for (i = 0; i < log->trace_len; i++)
> ? ? ? ? ? ? ? ?object->trace[i] = log->trace[i];
> ? ? ? ?object->trace_len = log->trace_len;
> ? ? ? ?spin_unlock_irqrestore(&object->lock, flags);
> +out:
> ? ? ? ?rcu_read_unlock();
> ?}
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at ?http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at ?http://www.tux.org/lkml/
>

2009-10-09 13:55:49

by Paul E. McKenney

[permalink] [raw]
Subject: Re: [PATCH 2/2] kmemleak: Check for NULL pointer returned by create_object()

On Fri, Oct 09, 2009 at 10:30:34AM +0100, Catalin Marinas wrote:
> This patch adds NULL pointer checking in the early_alloc() function.

Acked-by: Paul E. McKenney <[email protected]>

> Reported-by: Paul E. McKenney <[email protected]>
> Signed-off-by: Catalin Marinas <[email protected]>
> ---
> mm/kmemleak.c | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/mm/kmemleak.c b/mm/kmemleak.c
> index a617518..8bf765c 100644
> --- a/mm/kmemleak.c
> +++ b/mm/kmemleak.c
> @@ -834,11 +834,14 @@ static void early_alloc(struct early_log *log)
> rcu_read_lock();
> object = create_object((unsigned long)log->ptr, log->size,
> log->min_count, GFP_ATOMIC);
> + if (!object)
> + goto out;
> spin_lock_irqsave(&object->lock, flags);
> for (i = 0; i < log->trace_len; i++)
> object->trace[i] = log->trace[i];
> object->trace_len = log->trace_len;
> spin_unlock_irqrestore(&object->lock, flags);
> +out:
> rcu_read_unlock();
> }
>
>