public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2.6.10-rc2-bk15] sysfs_dir_close memory leak
@ 2004-12-03  2:50 Adam J. Richter
  2004-12-03  5:19 ` Chris Wright
  0 siblings, 1 reply; 6+ messages in thread
From: Adam J. Richter @ 2004-12-03  2:50 UTC (permalink / raw)
  To: maneesh; +Cc: akpm, chrisw, greg, linux-kernel, viro

	sysfs_dir_close did not free the "cursor" sysfs_dirent
used for keeping track of position in the list of sysfs_dirent nodes.
Consequently, doing a "find /sys" would leak a sysfs_dirent for
each of the 1140 directories in my /sys tree, or about 36kB
each time.

	This patch was generated against a sysfs tree with a
bunch of other changes, but should apply to the stock Linux tree
with the appropriate line number adjustments.

	If this patch looks OK, I would appreciate it if someone
would forward it downstream for integration.

                    __     ______________
Adam J. Richter        \ /
adam@yggdrasil.com      | g g d r a s i l


diff -u9 linux.prev/fs/sysfs/dir.c linux.noleak/fs/sysfs/dir.c
--- linux.prev/fs/sysfs/dir.c	2004-12-02 14:51:01.000000000 +0800
+++ linux.noleak/fs/sysfs/dir.c	2004-12-03 10:42:06.000000000 +0800
@@ -346,18 +346,21 @@
 static int sysfs_dir_close(struct inode *inode, struct file *file)
 {
 	struct dentry * dentry = file->f_dentry;
 	struct sysfs_dirent * cursor = file->private_data;
 
 	down(&dentry->d_inode->i_sem);
 	list_del_init(&cursor->s_sibling);
 	up(&dentry->d_inode->i_sem);
 
+	BUG_ON(cursor->s_dentry != NULL);
+	release_sysfs_dirent(cursor);
+
 	return 0;
 }
 
 /* Relationship between s_mode and the DT_xxx types */
 static inline unsigned char dt_type(struct sysfs_dirent *sd)
 {
 	return (sd->s_mode >> 12) & 15;
 }
 

^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: [PATCH 2.6.10-rc2-bk15] sysfs_dir_close memory leak
@ 2004-12-04  2:39 Adam J. Richter
  2004-12-04  7:35 ` Chris Wright
  0 siblings, 1 reply; 6+ messages in thread
From: Adam J. Richter @ 2004-12-04  2:39 UTC (permalink / raw)
  To: greg; +Cc: akpm, chrisw, linux-kernel, maneesh, viro

On Fri, 3 Dec 2004 10:56:31 -0800, Greg KH wrote:
>Thanks, I've deleted the BUG_ON() and will be sending the patch on to
>Linus in a bit.

	Great, thanks.

>(oh, care to add a "Signed-off-by:" line to your patches?)

	When we first started using Signed-off-by: lines, I did,
and then somebody commented on it to me in some way that gave me
the impression that the practice was only for people who "approve"
patches, but I'm happy to resume adding Signed-off-by: lines to all
of my patches that are proposed for integration in the future.

                    __     ______________
Adam J. Richter        \ /
adam@yggdrasil.com      | g g d r a s i l

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-12-04  7:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-03  2:50 [PATCH 2.6.10-rc2-bk15] sysfs_dir_close memory leak Adam J. Richter
2004-12-03  5:19 ` Chris Wright
2004-12-03 11:05   ` Adam J. Richter
2004-12-03 18:56     ` Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2004-12-04  2:39 Adam J. Richter
2004-12-04  7:35 ` Chris Wright

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox