From antoine@massena-4-82-67-196-50.fbx.proxad.net  Fri Feb 18 17:24:40 2005
Return-Path: <antoine@massena-4-82-67-196-50.fbx.proxad.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id DE13F16A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 18 Feb 2005 17:24:40 +0000 (GMT)
Received: from barton.dreadbsd.org (massena-4-82-67-196-50.fbx.proxad.net [82.67.196.50])
	by mx1.FreeBSD.org (Postfix) with ESMTP id E251743D3F
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 18 Feb 2005 17:24:39 +0000 (GMT)
	(envelope-from antoine@massena-4-82-67-196-50.fbx.proxad.net)
Received: from barton.dreadbsd.org (localhost [127.0.0.1])
	by barton.dreadbsd.org (8.13.3/8.13.1) with ESMTP id j1IHOb61001183
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 18 Feb 2005 18:24:37 +0100 (CET)
	(envelope-from antoine@massena-4-82-67-196-50.fbx.proxad.net)
Received: (from antoine@localhost)
	by barton.dreadbsd.org (8.13.3/8.13.1/Submit) id j1IHOaU9001182;
	Fri, 18 Feb 2005 18:24:36 +0100 (CET)
	(envelope-from antoine)
Message-Id: <200502181724.j1IHOaU9001182@barton.dreadbsd.org>
Date: Fri, 18 Feb 2005 18:24:36 +0100 (CET)
From: Antoine Brodin <antoine.brodin@laposte.net>
Reply-To: Antoine Brodin <antoine.brodin@laposte.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: Little memory leak in devfs
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         77685
>Category:       kern
>Synopsis:       Little memory leak in devfs
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Feb 18 17:30:16 GMT 2005
>Closed-Date:    Thu Mar 10 19:01:02 GMT 2005
>Last-Modified:  Thu Mar 10 19:01:02 GMT 2005
>Originator:     Antoine Brodin
>Release:        FreeBSD 6.0-CURRENT i386
>Organization:
None
>Environment:
System: FreeBSD barton.dreadbsd.org 6.0-CURRENT FreeBSD 6.0-CURRENT #1: Fri Feb 18 17:40:26 CET 2005 antoine@barton.dreadbsd.org:/usr/obj/usr/src/sys/BARTON i386
>Description:
There's a little leak in devfs: when destroying a device created by
make_dev_alias, the symlink is leaked.
When using MAC, the MAC label is probably leaked too but I don't use
MAC so somebody who uses MAC should test it.
>How-To-Repeat:
The is an easy way to reproduce and to see this leak:

celeron# vmstat -m | grep DEVFS 
        DEVFS   136    20K     20K      245  16,32,128,4096
celeron# ifconfig lo1 create
celeron# ls /dev
celeron# vmstat -m | grep DEVFS
        DEVFS   139    20K     20K      248  16,32,128,4096
celeron# ifconfig lo1 destroy
celeron# ls /dev
celeron# vmstat -m | grep DEVFS
        DEVFS   137    20K     20K      248  16,32,128,4096

On a patched box:

barton# vmstat -m | grep DEVFS
        DEVFS   162    23K     23K      166  16,32,128,4096
barton# ifconfig lo1 create
barton# ls /dev
barton# vmstat -m | grep DEVFS
        DEVFS   165    23K     23K      169  16,32,128,4096
barton# ifconfig lo1 destroy
barton# ls /dev
barton# vmstat -m | grep DEVFS
        DEVFS   162    23K     23K      169  16,32,128,4096

>Fix:
Apply the attached patch, the MAC part is untested.

--- devfs_devs.diff begins here ---
Index: devfs_devs.c
===================================================================
RCS file: /home/ncvs/src/sys/fs/devfs/devfs_devs.c,v
retrieving revision 1.33
diff -u -p -r1.33 devfs_devs.c
--- devfs_devs.c	10 Feb 2005 12:22:17 -0000	1.33
+++ devfs_devs.c	18 Feb 2005 16:53:59 -0000
@@ -270,10 +270,7 @@ devfs_populate(struct devfs_mount *dm)
 			if (dev == NULL && de != NULL) {
 				dd = de->de_dir;
 				*dep = NULL;
-				TAILQ_REMOVE(&dd->de_dlist, de, de_list);
-				if (de->de_vnode)
-					de->de_vnode->v_data = NULL;
-				FREE(de, M_DEVFS);
+				devfs_delete(dd, de);
 				devfs_dropref(i);
 				continue;
 			}
--- devfs_devs.diff ends here ---


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: phk 
State-Changed-When: Thu Mar 10 19:00:44 GMT 2005 
State-Changed-Why:  
Committed, thanks! 


http://www.freebsd.org/cgi/query-pr.cgi?pr=77685 
>Unformatted:
