From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KVuoN-0001BW-5e for mharc-grub-devel@gnu.org; Wed, 20 Aug 2008 17:01:47 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KVuoL-0001BR-E3 for grub-devel@gnu.org; Wed, 20 Aug 2008 17:01:45 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KVuoJ-0001Ar-J6 for grub-devel@gnu.org; Wed, 20 Aug 2008 17:01:45 -0400 Received: from [199.232.76.173] (port=49435 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KVuoJ-0001Ao-Fc for grub-devel@gnu.org; Wed, 20 Aug 2008 17:01:43 -0400 Received: from moutng.kundenserver.de ([212.227.126.187]:52675) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KVuoH-0002UA-Ks for grub-devel@gnu.org; Wed, 20 Aug 2008 17:01:43 -0400 Received: from [85.180.46.140] (e180046140.adsl.alicedsl.de [85.180.46.140]) by mrelayeu.kundenserver.de (node=mrelayeu4) with ESMTP (Nemesis) id 0ML21M-1KVuo236fP-0007zw; Wed, 20 Aug 2008 23:01:27 +0200 From: Felix Zielcke To: The development of GRUB 2 Content-Type: multipart/mixed; boundary="=-VYfzV/VjDSnmms7oblif" Date: Wed, 20 Aug 2008 23:01:26 +0200 Message-Id: <1219266086.4903.37.camel@fz.local> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 X-Provags-ID: V01U2FsdGVkX18I87RgjR/qGyLTqDwKSEZn+fE4MiqWK9Q/Cx7 TJ7KGECehZf29q+1TH5aOqB9UImjOOcSPP0whbsZWCVZvZhC/4 L0rt41W+6EAYjLSN4ejW00zXM+we8oO X-detected-kernel: by monty-python.gnu.org: Linux 2.6? (barebone, rare!) Subject: [PATCH] fix for a memleak in grub_ntfs_mount 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: Wed, 20 Aug 2008 21:01:45 -0000 --=-VYfzV/VjDSnmms7oblif Content-Type: text/plain Content-Transfer-Encoding: 7bit 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. --=-VYfzV/VjDSnmms7oblif Content-Disposition: attachment; filename=ntfs_memleak.diff Content-Type: text/x-patch; name=ntfs_memleak.diff; charset=UTF-8 Content-Transfer-Encoding: 7bit 2008-08-20 Felix Zielcke * 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; } --=-VYfzV/VjDSnmms7oblif Content-Disposition: attachment; filename=valgrind.log Content-Type: text/x-log; name=valgrind.log; charset=UTF-8 Content-Transfer-Encoding: 7bit ==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 --=-VYfzV/VjDSnmms7oblif--