From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1MSd4C-0001qI-Ey for mharc-grub-devel@gnu.org; Sun, 19 Jul 2009 16:33:04 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MSd4A-0001pj-It for grub-devel@gnu.org; Sun, 19 Jul 2009 16:33:02 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MSd45-0001pH-4O for grub-devel@gnu.org; Sun, 19 Jul 2009 16:33:02 -0400 Received: from [199.232.76.173] (port=48371 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MSd44-0001pE-VJ for grub-devel@gnu.org; Sun, 19 Jul 2009 16:32:57 -0400 Received: from c60.cesmail.net ([216.154.195.49]:21939) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.60) (envelope-from ) id 1MSd43-0004lb-S1 for grub-devel@gnu.org; Sun, 19 Jul 2009 16:32:56 -0400 Received: from unknown (HELO smtprelay2.cesmail.net) ([192.168.1.112]) by c60.cesmail.net with ESMTP; 19 Jul 2009 16:32:53 -0400 Received: from [192.168.0.22] (static-72-92-88-10.phlapa.fios.verizon.net [72.92.88.10]) by smtprelay2.cesmail.net (Postfix) with ESMTPSA id 99A7F34C88 for ; Sun, 19 Jul 2009 16:43:01 -0400 (EDT) From: Pavel Roskin To: The development of GRUB 2 In-Reply-To: References: <20090719011129.nnkkuesb4cwwwoos-cebfxv@webmail.spamcop.net> <1248033367.2519.11.camel@mj> Content-Type: text/plain Date: Sun, 19 Jul 2009 16:32:52 -0400 Message-Id: <1248035572.2519.34.camel@mj> Mime-Version: 1.0 X-Mailer: Evolution 2.26.3 (2.26.3-1.fc11) Content-Transfer-Encoding: 7bit X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: Re: [PATCH] AFS fixes and improvements X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Jul 2009 20:33:02 -0000 On Sun, 2009-07-19 at 22:23 +0200, Vladimir 'phcoder' Serbinenko wrote: > Yes, I did it too and valgrind only issued some warnings about my -O3 > libraries and found a memory leak caused by pc_partition_map_parse. I know. > This function anyway will be removed with my nested partition patch > (BTW I rediffed and resent it and it works fine here (plain and bsd > configurations). Tomorrow I'll test it with opensolaris). I prefer not to fix minor memory leaks by huge patches. I have a patch, I just wanted to look at the possibility to use grub_kzalloc() and allocating data as part of the partition. Anyway, here is the preliminary version. Fix memory leak in grub_disk_close() * kern/disk.c (grub_disk_close): Free disk->partition->data. * partmap/acorn.c (acorn_partition_map_probe): Set data to NULL. * partmap/amiga.c (amiga_partition_map_iterate): Likewise. * partmap/apple.c (apple_partition_map_iterate): Likewise. * partmap/gpt.c (gpt_partition_map_iterate): Likewise. We never use it. --- kern/disk.c | 3 +++ partmap/acorn.c | 1 + partmap/amiga.c | 1 + partmap/apple.c | 1 + partmap/gpt.c | 2 +- 5 files changed, 7 insertions(+), 1 deletions(-) diff --git a/kern/disk.c b/kern/disk.c index e463626..e6d6ab6 100644 --- a/kern/disk.c +++ b/kern/disk.c @@ -338,6 +338,9 @@ grub_disk_close (grub_disk_t disk) /* Reset the timer. */ grub_last_time = grub_get_time_ms (); + if (disk->partition) + grub_free (disk->partition->data); + grub_free (disk->partition); grub_free ((void *) disk->name); grub_free (disk); diff --git a/partmap/acorn.c b/partmap/acorn.c index 42fd61f..ef12043 100644 --- a/partmap/acorn.c +++ b/partmap/acorn.c @@ -164,6 +164,7 @@ acorn_partition_map_probe (grub_disk_t disk, const char *str) p->len = map[partnum].size; p->offset = 6; p->index = partnum; + p->data = NULL; return p; fail: diff --git a/partmap/amiga.c b/partmap/amiga.c index ffb807f..91289d4 100644 --- a/partmap/amiga.c +++ b/partmap/amiga.c @@ -124,6 +124,7 @@ amiga_partition_map_iterate (grub_disk_t disk, part.offset = (grub_off_t) next * 512; part.index = partno; + part.data = NULL; part.partmap = &grub_amiga_partition_map; if (hook (disk, &part)) diff --git a/partmap/apple.c b/partmap/apple.c index fce2f2c..6d673ad 100644 --- a/partmap/apple.c +++ b/partmap/apple.c @@ -146,6 +146,7 @@ apple_partition_map_iterate (grub_disk_t disk, part.len = grub_be_to_cpu32 (apart.blockcnt); part.offset = pos; part.index = partno; + part.data = NULL; grub_dprintf ("partition", "partition %d: name %s, type %s, start 0x%x, len 0x%x\n", diff --git a/partmap/gpt.c b/partmap/gpt.c index d646d41..35a979d 100644 --- a/partmap/gpt.c +++ b/partmap/gpt.c @@ -92,7 +92,7 @@ gpt_partition_map_iterate (grub_disk_t disk, part.offset = entries; part.index = i; part.partmap = &grub_gpt_partition_map; - part.data = &entry; + part.data = NULL; grub_dprintf ("gpt", "GPT entry %d: start=%lld, length=%lld\n", i, (unsigned long long) part.start, -- Regards, Pavel Roskin