All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Huang Shijie <shijie8@gmail.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
	lkml <linux-kernel@vger.kernel.org>
Subject: [PATCH] percpu: fix a memory leak in pcpu_extend_area_map()
Date: Sun, 08 Aug 2010 14:42:57 +0200	[thread overview]
Message-ID: <4C5EA651.7080009@kernel.org> (raw)
In-Reply-To: <1281261197-8816-1-git-send-email-shijie8@gmail.com>

>From 206c53730b8b1707becca7a868ea8d14ebee24d2 Mon Sep 17 00:00:00 2001
From: Huang Shijie <shijie8@gmail.com>
Date: Sun, 8 Aug 2010 14:39:07 +0200

The original code did not free the old map.  This patch fixes it.

tj: use @old as memcpy source instead of @chunk->map, and indentation
    and description update

Signed-off-by: Huang Shijie <shijie8@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
---
Patch applied to percpu#for-linus w/ some updates.  Thanks a lot for
catching this.

 mm/percpu.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/mm/percpu.c b/mm/percpu.c
index e61dc2c..a1830d8 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -393,7 +393,9 @@ static int pcpu_extend_area_map(struct pcpu_chunk *chunk, int new_alloc)
 		goto out_unlock;

 	old_size = chunk->map_alloc * sizeof(chunk->map[0]);
-	memcpy(new, chunk->map, old_size);
+	old = chunk->map;
+
+	memcpy(new, old, old_size);

 	chunk->map_alloc = new_alloc;
 	chunk->map = new;
-- 
1.7.1


WARNING: multiple messages have this Message-ID (diff)
From: Tejun Heo <tj@kernel.org>
To: Huang Shijie <shijie8@gmail.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
	lkml <linux-kernel@vger.kernel.org>
Subject: [PATCH] percpu: fix a memory leak in pcpu_extend_area_map()
Date: Sun, 08 Aug 2010 14:42:57 +0200	[thread overview]
Message-ID: <4C5EA651.7080009@kernel.org> (raw)
In-Reply-To: <1281261197-8816-1-git-send-email-shijie8@gmail.com>



  reply	other threads:[~2010-08-08 12:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-08  9:53 [PATCH] percpu : fix the memory leak Huang Shijie
2010-08-08 12:42 ` Tejun Heo [this message]
2010-08-08 12:42   ` [PATCH] percpu: fix a memory leak in pcpu_extend_area_map() Tejun Heo
2010-08-26 22:10   ` Andrew Morton
2010-08-26 22:10     ` Andrew Morton
2010-08-27  9:32     ` Tejun Heo
2010-08-27  9:32       ` Tejun Heo
2010-09-16 21:36   ` breaks 2.6.32.21+ (was: [PATCH] percpu: fix a memory leak in pcpu_extend_area_map()) Peter Palfrader
2010-09-16 21:36     ` Peter Palfrader
2010-09-16 23:13     ` [stable] " Greg KH
2010-09-16 23:13       ` Greg KH
2010-09-17 13:47       ` [stable] breaks 2.6.32.21+ Tejun Heo
2010-09-17 13:47         ` Tejun Heo
2010-09-17 16:36         ` Greg KH
2010-09-17 16:36           ` Greg KH

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=4C5EA651.7080009@kernel.org \
    --to=tj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=shijie8@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.