From nobody@FreeBSD.org  Tue Nov 13 09:02:00 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id F3C9916A419
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 13 Nov 2007 09:01:59 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id E1F2F13C4B9
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 13 Nov 2007 09:01:59 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.1/8.14.1) with ESMTP id lAD91Vos028592
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 13 Nov 2007 09:01:31 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.1/8.14.1/Submit) id lAD91V1R028591;
	Tue, 13 Nov 2007 09:01:31 GMT
	(envelope-from nobody)
Message-Id: <200711130901.lAD91V1R028591@www.freebsd.org>
Date: Tue, 13 Nov 2007 09:01:31 GMT
From: Ighighi <ighighi@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch]: Memory leak in NTFS when unloading module
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         118017
>Category:       kern
>Synopsis:       [nfts] [patch]: Memory leak in NTFS when unloading module
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Nov 13 09:10:02 UTC 2007
>Closed-Date:    Thu Nov 29 19:02:41 UTC 2007
>Last-Modified:  Thu Nov 29 19:02:41 UTC 2007
>Originator:     Ighighi
>Release:        6.3-PRERELEASE (RELENG_6)
>Organization:
>Environment:
FreeBSD orion 6.3-PRERELEASE FreeBSD 6.3-PRERELEASE #0: Mon Nov 12 08:12:36 VET 2007     root@orion:/usr/obj/usr/src/sys/CUSTOM  i386
>Description:
When unloading ntfs.ko with kldunload(8), the following message appears in syslog:

"Warning: memory type NTFS nthash leaked memory on destroy (1 allocations, 65536 bytes leaked)."

The bug is in src/sys/fs/ntfs/ntfs_ihash.c
ntfs_nthashdestroy() is supposed to call hashdestroy(9) on ntfs_nthashtbl since
the latter was allocated with hashinit(9).

I've seen this message since 6.1.  By looking at the sources for -CURRENT and
RELENG_7, it seems to me that they also contain this bug.
>How-To-Repeat:
/sbin/umount -v -t ntfs -a
/sbin/kldunload -v ntfs.ko
grep nthash /var/log/messages
>Fix:
The attached patch was successfully built and tested on FreeBSD 6.3-PRERELEASE.


Patch attached with submission follows:

--- src/sys/fs/ntfs/ntfs_ihash.c.orig	2005-01-06 14:10:39.000000000 -0400
+++ src/sys/fs/ntfs/ntfs_ihash.c	2007-11-13 03:59:58.252339682 -0400
@@ -73,6 +73,7 @@ ntfs_nthashinit()
 void
 ntfs_nthashdestroy(void)
 {
+	hashdestroy(ntfs_nthashtbl, M_NTFSNTHASH, ntfs_nthash);
 	lockdestroy(&ntfs_hashlock);
 	mtx_destroy(&ntfs_nthash_mtx);
 }


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->patched 
State-Changed-By: maxim 
State-Changed-When: Tue Nov 13 19:34:41 UTC 2007 
State-Changed-Why:  
Fixed in HEAD.  Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=118017 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/118017: commit references a PR
Date: Tue, 13 Nov 2007 19:34:12 +0000 (UTC)

 maxim       2007-11-13 19:34:06 UTC
 
   FreeBSD src repository
 
   Modified files:
     sys/fs/ntfs          ntfs_ihash.c 
   Log:
   o Do not leak inodes hash table at module unload.
   
   PR:             kern/118017
   Submitted by:   Ighighi
   MFC after:      1 week
   
   Revision  Changes    Path
   1.23      +1 -0      src/sys/fs/ntfs/ntfs_ihash.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: maxim 
State-Changed-When: Thu Nov 29 19:02:22 UTC 2007 
State-Changed-Why:  
Merged to RELENG_7. 

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