[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] AFS fixes and improvements
From: |
Pavel Roskin |
Subject: |
Re: [PATCH] AFS fixes and improvements |
Date: |
Sun, 19 Jul 2009 16:32:52 -0400 |
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
- [PATCH] AFS fixes and improvements, Vladimir 'phcoder' Serbinenko, 2009/07/17
- Re: [PATCH] AFS fixes and improvements, Vladimir 'phcoder' Serbinenko, 2009/07/17
- Re: [PATCH] AFS fixes and improvements, Pavel Roskin, 2009/07/19
- Re: [PATCH] AFS fixes and improvements, Vladimir 'phcoder' Serbinenko, 2009/07/19
- Re: [PATCH] AFS fixes and improvements, Vladimir 'phcoder' Serbinenko, 2009/07/19
- Re: [PATCH] AFS fixes and improvements, Pavel Roskin, 2009/07/19
- Re: [PATCH] AFS fixes and improvements, Vladimir 'phcoder' Serbinenko, 2009/07/19
- Re: [PATCH] AFS fixes and improvements,
Pavel Roskin <=
- Re: [PATCH] AFS fixes and improvements, Vladimir 'phcoder' Serbinenko, 2009/07/19
- Re: [PATCH] AFS fixes and improvements, Pavel Roskin, 2009/07/19
- Re: [PATCH] AFS fixes and improvements, Vladimir 'phcoder' Serbinenko, 2009/07/20
- Re: [PATCH] AFS fixes and improvements, Pavel Roskin, 2009/07/20
- Re: [PATCH] AFS fixes and improvements, Vladimir 'phcoder' Serbinenko, 2009/07/20
- Re: [PATCH] AFS fixes and improvements, Pavel Roskin, 2009/07/20
- Re: [PATCH] AFS fixes and improvements, Pavel Roskin, 2009/07/19
- Re: [PATCH] AFS fixes and improvements, Vladimir 'phcoder' Serbinenko, 2009/07/19