linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] small memory leak in autofs4 inode.c
@ 2003-11-10 14:59 Ian Kent
  0 siblings, 0 replies; only message in thread
From: Ian Kent @ 2003-11-10 14:59 UTC (permalink / raw)
  To: Marcello Tosatti, Linus Torvalds; +Cc: Kernel Mailing List, Jeremy Fitzhardinge


The attached patch corrects a memory leak in autofs4 inode.c. It applies 
to both kernel versions 2.4 and 2.6 (with a little fuzz).

An autofs_info struct is allocated in autofs4_read_super 
(autofs4_fill_super in 2.6) for use during superblock initialisation, its 
reference is not stored anywhere and it is not freed.

I thought it better to leave the allocation and then free it rather that 
allocate it n the stack. If this is not the best way to solve this problem 
please offer comments.

Regards
Ian Kent

--- inode.c.orig	2003-11-09 15:47:25.000000000 +0800
+++ inode.c	2003-11-09 15:49:09.000000000 +0800
@@ -183,6 +183,7 @@
 	struct file * pipe;
 	int pipefd;
 	struct autofs_sb_info *sbi;
+	struct autofs_info *ino;
 	int minproto, maxproto;
 
 	sbi = (struct autofs_sb_info *) kmalloc(sizeof(*sbi), GFP_KERNEL);
@@ -211,7 +212,9 @@
 	/*
 	 * Get the root inode and dentry, but defer checking for errors.
 	 */
-	root_inode = autofs4_get_inode(s, autofs4_mkroot(sbi));
+	ino = autofs4_mkroot(sbi);
+	root_inode = autofs4_get_inode(s, ino);
+	kfree(ino);
 	root_inode->i_op = &autofs4_root_inode_operations;
 	root_inode->i_fop = &autofs4_root_operations;
 	root = d_alloc_root(root_inode);

-- 

   ,-._|\    Ian Kent
  /      \   Perth, Western Australia
  *_.--._/   E-mail: raven@themaw.net
        v    Web: http://themaw.net/


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-11-10 14:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-10 14:59 [PATCH] small memory leak in autofs4 inode.c Ian Kent

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).