From: Felix Zielcke <fzielcke@z-51.de>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: [PATCH] fix for a memleak in grub_ntfs_mount
Date: Wed, 20 Aug 2008 23:01:26 +0200 [thread overview]
Message-ID: <1219266086.4903.37.camel@fz.local> (raw)
[-- 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
next reply other threads:[~2008-08-20 21:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-20 21:01 Felix Zielcke [this message]
2008-08-21 13:14 ` [PATCH] fix for a memleak in grub_ntfs_mount Robert Millan
2008-08-21 13:31 ` Felix Zielcke
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=1219266086.4903.37.camel@fz.local \
--to=fzielcke@z-51.de \
--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.