Skip to contentSkip to conversation

memory leak in dentry_open()

PATCH New Peter Staubach 1 participant 1 message Nov 3, 2005 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 memory leak in dentry_open()

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

fs/open.c renamed from fs/open.c.org +4 -1
@@ -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);
 }