linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Neil Brown <neilb@cse.unsw.edu.au>
To: Zwane Mwaikambo <zwane@linuxpower.ca>
Cc: pee@erkkila.org, Helge Hafting <helgehaf@aitel.hist.no>,
	William Lee Irwin III <wli@holomorphy.com>,
	Andrew Morton <akpm@digeo.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: 2.5.70-mm1 bootcrash, possibly RAID-1
Date: Fri, 30 May 2003 11:59:30 +1000	[thread overview]
Message-ID: <16086.47874.272564.71572@notabene.cse.unsw.edu.au> (raw)
In-Reply-To: message from Zwane Mwaikambo on Thursday May 29

On Thursday May 29, zwane@linuxpower.ca wrote:
> How does the following patch look for the double free.
> 

Thanks. It is a good start, but there are other problems with freeing
things on error paths.   This patch should fix it all.

NeilBrown

--------------------------------------------
Fix up freeing of kmalloc structures

Some paths free things twice, others free un-initialised values :-(
Not any more.


 ----------- Diffstat output ------------
 ./drivers/md/raid0.c |   17 ++++++++---------
 1 files changed, 8 insertions(+), 9 deletions(-)

diff ./drivers/md/raid0.c~current~ ./drivers/md/raid0.c
--- ./drivers/md/raid0.c~current~	2003-05-30 11:40:06.000000000 +1000
+++ ./drivers/md/raid0.c	2003-05-30 11:47:03.000000000 +1000
@@ -85,10 +85,8 @@ static int create_strip_zones (mddev_t *
 	conf->devlist = kmalloc(sizeof(mdk_rdev_t*)*
 				conf->nr_strip_zones*mddev->raid_disks,
 				GFP_KERNEL);
-	if (!conf->devlist) {
-		kfree(conf);
+	if (!conf->devlist)
 		return 1;
-	}
 
 	memset(conf->strip_zone, 0,sizeof(struct strip_zone)*
 				   conf->nr_strip_zones);
@@ -235,6 +233,8 @@ static int raid0_run (mddev_t *mddev)
 		goto out;
 	mddev->private = (void *)conf;
  
+	mddev->strip_zone = NULL;
+	mddev->devlist = NULL;
 	if (create_strip_zones (mddev)) 
 		goto out_free_conf;
 
@@ -273,7 +273,7 @@ static int raid0_run (mddev_t *mddev)
 				nb_zone*sizeof(struct strip_zone*));
 	conf->hash_table = kmalloc (sizeof (struct strip_zone *)*nb_zone, GFP_KERNEL);
 	if (!conf->hash_table)
-		goto out_free_zone_conf;
+		goto out_free_conf;
 	size = conf->strip_zone[cur].size;
 
 	for (i=0; i< nb_zone; i++) {
@@ -296,12 +296,11 @@ static int raid0_run (mddev_t *mddev)
 	blk_queue_merge_bvec(&mddev->queue, raid0_mergeable_bvec);
 	return 0;
 
-out_free_zone_conf:
-	kfree(conf->strip_zone);
-	conf->strip_zone = NULL;
-
 out_free_conf:
-	kfree (conf->devlist);
+	if (conf->strip_zone)
+		kfree(conf->strip_zone);
+	if (conf->devlist)
+		kfree (conf->devlist);
 	kfree(conf);
 	mddev->private = NULL;
 out:
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>

  reply	other threads:[~2003-05-30  1:59 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-08 11:22 2.5.67-mm1 Andrew Morton
2003-04-08 13:01 ` 2.5.67-mm1 William Lee Irwin III
2003-04-08 13:17 ` 2.5.67-mm1 Ed Tomlinson
2003-04-08 15:31   ` 2.5.67-mm1 Randy.Dunlap
2003-04-08 15:39     ` 2.5.67-mm1 Ed Tomlinson
2003-04-08 16:14       ` 2.5.67-mm1 Randy.Dunlap
2003-04-08 16:18     ` 2.5.67-mm1 Ed Tomlinson
2003-04-08 16:10   ` 2.5.67-mm1 Andrew Morton
2003-04-08 16:50     ` 2.5.67-mm1 Ed Tomlinson
2003-04-08 14:08 ` 2.5.67-mm1 William Lee Irwin III
2003-04-08 16:43 ` 2.5.67-mm1 Helge Hafting
2003-04-09  9:42 ` 2.5.67-mm1 cause framebuffer crash at bootup Helge Hafting
     [not found]   ` <20030409030534.619f7fa0.akpm@digeo.com>
2003-04-09 10:05     ` Andrew Morton
     [not found]   ` <20030409031845.185d853f.akpm@digeo.com>
2003-04-09 10:18     ` Andrew Morton
2003-04-09 20:30       ` Randy.Dunlap
2003-05-28 11:14 ` 2.5.67-mm1 bootcrash, possibly IDE or RAID Helge Hafting
2003-05-28 11:13   ` William Lee Irwin III
2003-05-28 11:34     ` 2.5.70-mm1 " Helge Hafting
2003-05-28 11:35       ` William Lee Irwin III
2003-05-28 22:59         ` 2.5.70-mm1 bootcrash, possibly RAID-1 Helge Hafting
2003-05-28 23:18           ` Andrew Morton
2003-05-28 23:30           ` Paul E. Erkkila
2003-05-29  1:08             ` Neil Brown
2003-05-29  7:14               ` Zwane Mwaikambo
2003-05-29  7:32                 ` Zwane Mwaikambo
2003-05-30  1:59                   ` Neil Brown [this message]
2003-05-31 16:13                     ` Paul E. Erkkila
2003-05-29  4:27           ` Alain Toussaint
2003-05-29 13:22           ` John Stoffel

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=16086.47874.272564.71572@notabene.cse.unsw.edu.au \
    --to=neilb@cse.unsw.edu.au \
    --cc=akpm@digeo.com \
    --cc=helgehaf@aitel.hist.no \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=pee@erkkila.org \
    --cc=wli@holomorphy.com \
    --cc=zwane@linuxpower.ca \
    /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