[PATCH] small memory leak in autofs4 inode.c

From: Ian Kent
Date: Mon Nov 10 2003 - 09:56:43 EST



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@xxxxxxxxxx
v Web: http://themaw.net/

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/