* [PATCH] fix for a memleak in grub_ntfs_mount
@ 2008-08-20 21:01 Felix Zielcke
2008-08-21 13:14 ` Robert Millan
0 siblings, 1 reply; 3+ messages in thread
From: Felix Zielcke @ 2008-08-20 21:01 UTC (permalink / raw)
To: The development of GRUB 2
[-- Attachment #1: Type: text/plain, Size: 758 bytes --]
I have just run valgrind on grub-probe /
Attached is a patch to fix a memleak in grub_ntfs_mount, which is very
obvious if you look at the code.
Probable there's nothing wrong with it and I could just commit it, but
as always I want to be sure :)
I attached the full valgrind output too.
Though it's with grub-probe compiled with the ntfs fix so it doestn't
appear there.
The first one:
==11709== by 0x40431F: grub_guess_root_device (getroot.c:379)
==11709== by 0x4016CC: probe (grub-probe.c:122)
is about device_name in probe ()
Not a real problem and too fix it you'd need to introduce a temporary
variable just to make valgrind happy.
For the others I wasn't yet able to find out if they're real problems or
if it just valgrind is confused.
[-- Attachment #2: ntfs_memleak.diff --]
[-- Type: text/x-patch, Size: 389 bytes --]
2008-08-20 Felix Zielcke <fzielcke@z-51.de>
* fs/ntfs.c (grub_ntfs_mount): Fix a memory leak.
Index: fs/ntfs.c
===================================================================
--- fs/ntfs.c (Revision 1822)
+++ fs/ntfs.c (Arbeitskopie)
@@ -850,6 +850,7 @@ fail:
{
free_file (&data->mmft);
free_file (&data->cmft);
+ grub_free (data);
}
return 0;
}
[-- Attachment #3: valgrind.log --]
[-- Type: text/x-log, Size: 10122 bytes --]
==11709== Memcheck, a memory error detector.
==11709== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==11709== Using LibVEX rev 1854, a library for dynamic binary translation.
==11709== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==11709== Using valgrind-3.3.1-Debian, a dynamic binary instrumentation framework.
==11709== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==11709== For more details, rerun with: -v
==11709==
==11709== My PID = 11709, parent PID = 10584. Prog and args are:
==11709== ./grub-probe
==11709== /
==11709==
==11709== Conditional jump or move depends on uninitialised value(s)
==11709== at 0x4015287: (within /lib/ld-2.8.so)
==11709== by 0x4004EF2: (within /lib/ld-2.8.so)
==11709== by 0x4007A48: (within /lib/ld-2.8.so)
==11709== by 0x4002EBB: (within /lib/ld-2.8.so)
==11709== by 0x4013CC4: (within /lib/ld-2.8.so)
==11709== by 0x4001308: (within /lib/ld-2.8.so)
==11709== by 0x4000A57: (within /lib/ld-2.8.so)
==11709== by 0x1: ???
==11709== by 0x7FF00093E: ???
==11709== by 0x7FF00094B: ???
==11709==
==11709== Conditional jump or move depends on uninitialised value(s)
==11709== at 0x401504E: (within /lib/ld-2.8.so)
==11709== by 0x40072CA: (within /lib/ld-2.8.so)
==11709== by 0x4007D15: (within /lib/ld-2.8.so)
==11709== by 0x400176A: (within /lib/ld-2.8.so)
==11709== by 0x400D205: (within /lib/ld-2.8.so)
==11709== by 0x400166E: (within /lib/ld-2.8.so)
==11709== by 0x4003AEF: (within /lib/ld-2.8.so)
==11709== by 0x4013CC4: (within /lib/ld-2.8.so)
==11709== by 0x4001308: (within /lib/ld-2.8.so)
==11709== by 0x4000A57: (within /lib/ld-2.8.so)
==11709== by 0x1: ???
==11709== by 0x7FF00093E: ???
==11709==
==11709== Conditional jump or move depends on uninitialised value(s)
==11709== at 0x4015059: (within /lib/ld-2.8.so)
==11709== by 0x40072CA: (within /lib/ld-2.8.so)
==11709== by 0x4007D15: (within /lib/ld-2.8.so)
==11709== by 0x400176A: (within /lib/ld-2.8.so)
==11709== by 0x400D205: (within /lib/ld-2.8.so)
==11709== by 0x400166E: (within /lib/ld-2.8.so)
==11709== by 0x4003AEF: (within /lib/ld-2.8.so)
==11709== by 0x4013CC4: (within /lib/ld-2.8.so)
==11709== by 0x4001308: (within /lib/ld-2.8.so)
==11709== by 0x4000A57: (within /lib/ld-2.8.so)
==11709== by 0x1: ???
==11709== by 0x7FF00093E: ???
==11709==
==11709== Conditional jump or move depends on uninitialised value(s)
==11709== at 0x4015064: (within /lib/ld-2.8.so)
==11709== by 0x40072CA: (within /lib/ld-2.8.so)
==11709== by 0x4007D15: (within /lib/ld-2.8.so)
==11709== by 0x400176A: (within /lib/ld-2.8.so)
==11709== by 0x400D205: (within /lib/ld-2.8.so)
==11709== by 0x400166E: (within /lib/ld-2.8.so)
==11709== by 0x4003AEF: (within /lib/ld-2.8.so)
==11709== by 0x4013CC4: (within /lib/ld-2.8.so)
==11709== by 0x4001308: (within /lib/ld-2.8.so)
==11709== by 0x4000A57: (within /lib/ld-2.8.so)
==11709== by 0x1: ???
==11709== by 0x7FF00093E: ???
==11709==
==11709== Conditional jump or move depends on uninitialised value(s)
==11709== at 0x40152A1: (within /lib/ld-2.8.so)
==11709== by 0x40072D7: (within /lib/ld-2.8.so)
==11709== by 0x4007D15: (within /lib/ld-2.8.so)
==11709== by 0x400176A: (within /lib/ld-2.8.so)
==11709== by 0x400D205: (within /lib/ld-2.8.so)
==11709== by 0x400166E: (within /lib/ld-2.8.so)
==11709== by 0x4003AEF: (within /lib/ld-2.8.so)
==11709== by 0x4013CC4: (within /lib/ld-2.8.so)
==11709== by 0x4001308: (within /lib/ld-2.8.so)
==11709== by 0x4000A57: (within /lib/ld-2.8.so)
==11709== by 0x1: ???
==11709== by 0x7FF00093E: ???
==11709==
==11709== Conditional jump or move depends on uninitialised value(s)
==11709== at 0x40152A1: (within /lib/ld-2.8.so)
==11709== by 0x400A13D: (within /lib/ld-2.8.so)
==11709== by 0x4005F57: (within /lib/ld-2.8.so)
==11709== by 0x4007DBC: (within /lib/ld-2.8.so)
==11709== by 0x400176A: (within /lib/ld-2.8.so)
==11709== by 0x400D205: (within /lib/ld-2.8.so)
==11709== by 0x400166E: (within /lib/ld-2.8.so)
==11709== by 0x4003AEF: (within /lib/ld-2.8.so)
==11709== by 0x4013CC4: (within /lib/ld-2.8.so)
==11709== by 0x4001308: (within /lib/ld-2.8.so)
==11709== by 0x4000A57: (within /lib/ld-2.8.so)
==11709== by 0x1: ???
==11709==
==11709== Conditional jump or move depends on uninitialised value(s)
==11709== at 0x400A851: (within /lib/ld-2.8.so)
==11709== by 0x400374A: (within /lib/ld-2.8.so)
==11709== by 0x4013CC4: (within /lib/ld-2.8.so)
==11709== by 0x4001308: (within /lib/ld-2.8.so)
==11709== by 0x4000A57: (within /lib/ld-2.8.so)
==11709== by 0x1: ???
==11709== by 0x7FF00093E: ???
==11709== by 0x7FF00094B: ???
==11709==
==11709== Conditional jump or move depends on uninitialised value(s)
==11709== at 0x400A85A: (within /lib/ld-2.8.so)
==11709== by 0x400374A: (within /lib/ld-2.8.so)
==11709== by 0x4013CC4: (within /lib/ld-2.8.so)
==11709== by 0x4001308: (within /lib/ld-2.8.so)
==11709== by 0x4000A57: (within /lib/ld-2.8.so)
==11709== by 0x1: ???
==11709== by 0x7FF00093E: ???
==11709== by 0x7FF00094B: ???
==11709== Warning: noted but unhandled ioctl 0x1261 with no size/direction hints
==11709== This could cause spurious value errors to appear.
==11709== See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.
==11709== Warning: noted but unhandled ioctl 0x1261 with no size/direction hints
==11709== This could cause spurious value errors to appear.
==11709== See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.
==11709== Warning: noted but unhandled ioctl 0x1261 with no size/direction hints
==11709== This could cause spurious value errors to appear.
==11709== See README_MISSING_SYSCALL_OR_IOCTL for guidance on writing a proper wrapper.
==11709==
==11709== ERROR SUMMARY: 8 errors from 8 contexts (suppressed: 0 from 0)
==11709== malloc/free: in use at exit: 90,406 bytes in 34 blocks.
==11709== malloc/free: 279 allocs, 245 frees, 564,287 bytes allocated.
==11709== For counts of detected errors, rerun with: -v
==11709== searching for pointers to 34 not-freed blocks.
==11709== checked 215,536 bytes.
==11709==
==11709==
==11709== 10 bytes in 1 blocks are definitely lost in loss record 2 of 15
==11709== at 0x4C20FEB: malloc (vg_replace_malloc.c:207)
==11709== by 0x4036B9: xmalloc (misc.c:95)
==11709== by 0x4041EB: find_root_device (getroot.c:248)
==11709== by 0x40431F: grub_guess_root_device (getroot.c:379)
==11709== by 0x4016CC: probe (grub-probe.c:122)
==11709== by 0x401D67: main (grub-probe.c:372)
==11709==
==11709==
==11709== 24 bytes in 1 blocks are definitely lost in loss record 3 of 15
==11709== at 0x4C20FEB: malloc (vg_replace_malloc.c:207)
==11709== by 0x4036B9: xmalloc (misc.c:95)
==11709== by 0x403AF0: grub_malloc (misc.c:236)
==11709== by 0x41D3A3: grub_partition_parse (pc.c:47)
==11709== by 0x41D9F4: pc_partition_map_probe (pc.c:255)
==11709== by 0x4080A8: part_map_probe.2036 (partition.c:66)
==11709== by 0x407FEF: grub_partition_map_iterate (partition.c:51)
==11709== by 0x408080: grub_partition_probe (partition.c:81)
==11709== by 0x404EE7: grub_disk_open (disk.c:273)
==11709== by 0x404643: grub_device_open (device.c:50)
==11709== by 0x4017EF: probe (grub-probe.c:166)
==11709== by 0x401D67: main (grub-probe.c:372)
==11709==
==11709==
==11709== 68 (64 direct, 4 indirect) bytes in 1 blocks are definitely lost in loss record 4 of 15
==11709== at 0x4C20FEB: malloc (vg_replace_malloc.c:207)
==11709== by 0x4036B9: xmalloc (misc.c:95)
==11709== by 0x403AF0: grub_malloc (misc.c:236)
==11709== by 0x404D58: grub_disk_open (disk.c:222)
==11709== by 0x4031A1: grub_util_biosdisk_get_grub_dev (biosdisk.c:860)
==11709== by 0x404555: grub_util_get_grub_dev (getroot.c:469)
==11709== by 0x40178F: probe (grub-probe.c:155)
==11709== by 0x401D67: main (grub-probe.c:372)
==11709==
==11709==
==11709== 96 bytes in 4 blocks are definitely lost in loss record 5 of 15
==11709== at 0x4C20FEB: malloc (vg_replace_malloc.c:207)
==11709== by 0x4036B9: xmalloc (misc.c:95)
==11709== by 0x403AF0: grub_malloc (misc.c:236)
==11709== by 0x41D3A3: grub_partition_parse (pc.c:47)
==11709== by 0x41D9F4: pc_partition_map_probe (pc.c:255)
==11709== by 0x4080A8: part_map_probe.2036 (partition.c:66)
==11709== by 0x407FEF: grub_partition_map_iterate (partition.c:51)
==11709== by 0x408080: grub_partition_probe (partition.c:81)
==11709== by 0x404EE7: grub_disk_open (disk.c:273)
==11709== by 0x42201A: hook.2567 (raid.c:600)
==11709== by 0x4047F6: iterate_partition.2158 (device.c:129)
==11709== by 0x41D724: pc_partition_map_iterate (pc.c:155)
==11709==
==11709==
==11709== 96 bytes in 4 blocks are definitely lost in loss record 6 of 15
==11709== at 0x4C20FEB: malloc (vg_replace_malloc.c:207)
==11709== by 0x4036B9: xmalloc (misc.c:95)
==11709== by 0x403AF0: grub_malloc (misc.c:236)
==11709== by 0x41D3A3: grub_partition_parse (pc.c:47)
==11709== by 0x41D9F4: pc_partition_map_probe (pc.c:255)
==11709== by 0x4080A8: part_map_probe.2036 (partition.c:66)
==11709== by 0x407FEF: grub_partition_map_iterate (partition.c:51)
==11709== by 0x408080: grub_partition_probe (partition.c:81)
==11709== by 0x404EE7: grub_disk_open (disk.c:273)
==11709== by 0x4202D4: grub_lvm_scan_device (lvm.c:224)
==11709== by 0x4047F6: iterate_partition.2158 (device.c:129)
==11709== by 0x41D724: pc_partition_map_iterate (pc.c:155)
==11709==
==11709== LEAK SUMMARY:
==11709== definitely lost: 290 bytes in 11 blocks.
==11709== indirectly lost: 4 bytes in 1 blocks.
==11709== possibly lost: 0 bytes in 0 blocks.
==11709== still reachable: 90,112 bytes in 22 blocks.
==11709== suppressed: 0 bytes in 0 blocks.
==11709== Reachable blocks (those to which a pointer was found) are not shown.
==11709== To see them, rerun with: --leak-check=full --show-reachable=yes
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fix for a memleak in grub_ntfs_mount
2008-08-20 21:01 [PATCH] fix for a memleak in grub_ntfs_mount Felix Zielcke
@ 2008-08-21 13:14 ` Robert Millan
2008-08-21 13:31 ` Felix Zielcke
0 siblings, 1 reply; 3+ messages in thread
From: Robert Millan @ 2008-08-21 13:14 UTC (permalink / raw)
To: The development of GRUB 2
On Wed, Aug 20, 2008 at 11:01:26PM +0200, Felix Zielcke wrote:
> 2008-08-20 Felix Zielcke <fzielcke@z-51.de>
>
> * fs/ntfs.c (grub_ntfs_mount): Fix a memory leak.
>
> Index: fs/ntfs.c
> ===================================================================
> --- fs/ntfs.c (Revision 1822)
> +++ fs/ntfs.c (Arbeitskopie)
> @@ -850,6 +850,7 @@ fail:
> {
> free_file (&data->mmft);
> free_file (&data->cmft);
> + grub_free (data);
> }
> return 0;
> }
Looks fine to me.
--
Robert Millan
The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
how) you may access your data; but nobody's threatening your freedom: we
still allow you to remove your data and not access it at all."
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fix for a memleak in grub_ntfs_mount
2008-08-21 13:14 ` Robert Millan
@ 2008-08-21 13:31 ` Felix Zielcke
0 siblings, 0 replies; 3+ messages in thread
From: Felix Zielcke @ 2008-08-21 13:31 UTC (permalink / raw)
To: The development of GRUB 2
Commited.
(Copyright of fs/ntfs.c has 2008 and Changelog has \t :))
Hopefully I can find out more about the other complains from valgrind.
Am Donnerstag, den 21.08.2008, 15:14 +0200 schrieb Robert Millan:
> On Wed, Aug 20, 2008 at 11:01:26PM +0200, Felix Zielcke wrote:
> > 2008-08-20 Felix Zielcke <fzielcke@z-51.de>
> >
> > * fs/ntfs.c (grub_ntfs_mount): Fix a memory leak.
> >
> > Index: fs/ntfs.c
> > ===================================================================
> > --- fs/ntfs.c (Revision 1822)
> > +++ fs/ntfs.c (Arbeitskopie)
> > @@ -850,6 +850,7 @@ fail:
> > {
> > free_file (&data->mmft);
> > free_file (&data->cmft);
> > + grub_free (data);
> > }
> > return 0;
> > }
>
> Looks fine to me.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-08-21 13:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-20 21:01 [PATCH] fix for a memleak in grub_ntfs_mount Felix Zielcke
2008-08-21 13:14 ` Robert Millan
2008-08-21 13:31 ` Felix Zielcke
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.