Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 Jul 2003 00:16:15 +0700 (NOVST)
From:      Alexey Dokuchaev <danfe@regency.nsu.ru>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/53980: [FIX] Better memory utilization in fstat(1)
Message-ID:  <200307011716.h61HGFjA056131@regency.nsu.ru>
Resent-Message-ID: <200307011720.h61HKA5N065804@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         53980
>Category:       bin
>Synopsis:       [FIX] Better memory utilization in fstat(1)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jul 01 10:20:10 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator:     Alexey Dokuchaev
>Release:        FreeBSD 5.1-CURRENT i386
>Organization:
CNIT NSU
>Environment:
System: FreeBSD cytherea.nsu.ru 5.1-CURRENT FreeBSD 5.1-CURRENT #6: Tue Jul 1 13:05:23 NOVT 2003 root@cytherea.nsu.ru:/usr/obj/usr/src/sys/CYTHEREA i386
>Description:
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.
>How-To-Repeat:
N/A
>Fix:
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 @@
 			dprintf(stderr,
 			    "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;
 }

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200307011716.h61HGFjA056131>