[PATCH] memory leak in dentry_open()
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. Signed-off-by: Peter Staubach <staubach@redhat.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
committed by
Linus Torvalds
parent
5c7ad5104d
commit
6fdcc21622
@@ -887,6 +887,10 @@ struct file *nameidata_to_filp(struct nameidata *nd, int flags)
|
|||||||
return filp;
|
return filp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* dentry_open() will have done dput(dentry) and mntput(mnt) if it returns an
|
||||||
|
* error.
|
||||||
|
*/
|
||||||
struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
|
struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
@@ -894,8 +898,11 @@ struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
|
|||||||
|
|
||||||
error = -ENFILE;
|
error = -ENFILE;
|
||||||
f = get_empty_filp();
|
f = get_empty_filp();
|
||||||
if (f == NULL)
|
if (f == NULL) {
|
||||||
|
dput(dentry);
|
||||||
|
mntput(mnt);
|
||||||
return ERR_PTR(error);
|
return ERR_PTR(error);
|
||||||
|
}
|
||||||
|
|
||||||
return __dentry_open(dentry, mnt, flags, f, NULL);
|
return __dentry_open(dentry, mnt, flags, f, NULL);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user