public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Michael Holzheu <holzheu@linux.vnet.ibm.com>
To: Tejun Heo <tj@kernel.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] percpu: Fix rollback in pcpu_embed_first_chunk()
Date: Wed, 9 May 2012 14:39:48 +0200	[thread overview]
Message-ID: <20120509143948.4ba4e949@br98xy6r> (raw)

From: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Subject: percpu: Fix rollback in pcpu_embed_first_chunk()

The "out_free_areas" rollback in pcpu_embed_first_chunk calls the
free_fn() function for all elements in area[]. This is not correct
because not all elements have been allocated.

To fix this we call free_fn() only for allocated elements.

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
---
diff --git a/mm/percpu.c b/mm/percpu.c
index f47af91..5a7f631 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1692,9 +1692,9 @@ int __init pcpu_embed_first_chunk(size_t reserved_size, size_t dyn_size,
 	goto out_free;
 
 out_free_areas:
-	for (group = 0; group < ai->nr_groups; group++)
-		free_fn(areas[group],
-			ai->groups[group].nr_units * ai->unit_size);
+	for (;group > 0; group--)
+		free_fn(areas[group - 1],
+			ai->groups[group - 1].nr_units * ai->unit_size);
 out_free:
 	pcpu_free_alloc_info(ai);
 	if (areas)


             reply	other threads:[~2012-05-09 12:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-09 12:39 Michael Holzheu [this message]
2012-05-09 17:06 ` [PATCH] percpu: Fix rollback in pcpu_embed_first_chunk() Tejun Heo

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=20120509143948.4ba4e949@br98xy6r \
    --to=holzheu@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@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