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.


2008-08-20  Felix Zielcke  <[EMAIL PROTECTED]>

	* 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;
 }
==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
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to