bin/53980: [FIX] Better memory utilization in fstat(1)

Alexey Dokuchaev danfe at
Tue Jul 1 10:20:12 PDT 2003

>Number:         53980
>Category:       bin
>Synopsis:       [FIX] Better memory utilization in fstat(1)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jul 01 10:20:10 PDT 2003
>Originator:     Alexey Dokuchaev
>Release:        FreeBSD 5.1-CURRENT i386
System: FreeBSD 5.1-CURRENT FreeBSD 5.1-CURRENT #6: Tue Jul 1 13:05:23 NOVT 2003 root at i386
When stating vnode on msdosfs (insice msdosfs_filestat()), memory is
being allocated, but never released during function execution.  Thus, it
seems that when fstat(1) run on msdosfs with some huge files on it, quite
a few memory could be allocated and never free until end of fstat(1)
execution.  While this probably rather hard to reveal under normal
circumastances, freeing memory still seems like a good practice to me,
since generally one could not bother freeing memory in main() or some
other being-called-one-time function, but forgetting about free() in
repeatedly called function is not that fair anymore.
Index: msdosfs.c
RCS file: /home/ncvs/src/usr.bin/fstat/msdosfs.c,v
retrieving revision 1.7
diff -u -r1.7 msdosfs.c
--- msdosfs.c	24 Jun 2003 08:18:18 -0000	1.7
+++ msdosfs.c	1 Jul 2003 16:56:37 -0000
@@ -107,6 +107,7 @@
 			    "can't read mount info at %p for pid %d\n",
 			    (void *)denode.de_pmp, Pid);
+			free(mnt);
 			return 0;
@@ -147,5 +148,6 @@
 	fsp->fileid = fileid;
+	free(mnt);
 	return 1;


More information about the freebsd-bugs mailing list