[PATCH] memory leak in dentry_open()

From: Peter Staubach
Date: Thu Nov 03 2005 - 16:09:23 EST


Hi.

There is a memory leak possible in dentry_open(). If get_empty_filp()
fails, then the references to dentry and mnt need to be released.
The attached patch adds the calls to dput() and mntput() to release
these two references.

Thanx...

ps

Signed-off-by: Peter Staubach <staubach@xxxxxxxxxx> --- linux-2.6.14/fs/open.c.org
+++ linux-2.6.14/fs/open.c
@@ -894,8 +894,11 @@ struct file *dentry_open(struct dentry *

error = -ENFILE;
f = get_empty_filp();
- if (f == NULL)
+ if (f == NULL) {
+ dput(dentry);
+ mntput(mnt);
return ERR_PTR(error);
+ }

return __dentry_open(dentry, mnt, flags, f, NULL);
}