From: Pavel Roskin <proski@gnu.org>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: [PATCH] AFS fixes and improvements
Date: Sun, 19 Jul 2009 16:32:52 -0400 [thread overview]
Message-ID: <1248035572.2519.34.camel@mj> (raw)
In-Reply-To: <d7ead6de0907191323o7d2e8c0aidd75cad779d9af2a@mail.gmail.com>
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
next prev parent reply other threads:[~2009-07-19 20:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-17 19:30 [PATCH] AFS fixes and improvements Vladimir 'phcoder' Serbinenko
2009-07-17 22:35 ` Vladimir 'phcoder' Serbinenko
2009-07-19 5:11 ` Pavel Roskin
2009-07-19 13:20 ` Vladimir 'phcoder' Serbinenko
2009-07-19 15:34 ` Vladimir 'phcoder' Serbinenko
2009-07-19 19:56 ` Pavel Roskin
2009-07-19 20:23 ` Vladimir 'phcoder' Serbinenko
2009-07-19 20:32 ` Pavel Roskin [this message]
2009-07-19 20:40 ` Vladimir 'phcoder' Serbinenko
2009-07-19 20:47 ` Pavel Roskin
2009-07-20 9:36 ` Vladimir 'phcoder' Serbinenko
2009-07-20 18:34 ` Pavel Roskin
2009-07-20 18:56 ` Vladimir 'phcoder' Serbinenko
2009-07-20 19:36 ` Pavel Roskin
2009-07-19 20:10 ` Pavel Roskin
2009-07-19 20:18 ` Vladimir 'phcoder' Serbinenko
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=1248035572.2519.34.camel@mj \
--to=proski@gnu.org \
--cc=grub-devel@gnu.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 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.