Explorar o código

fix leak in __logfs_create()

if kmalloc fails, we still need to drop the inode, as we do
on other failure exits.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Al Viro %!s(int64=15) %!d(string=hai) anos
pai
achega
256249584b
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      fs/logfs/dir.c

+ 4 - 1
fs/logfs/dir.c

@@ -434,8 +434,11 @@ static int __logfs_create(struct inode *dir, struct dentry *dentry,
 	int ret;
 
 	ta = kzalloc(sizeof(*ta), GFP_KERNEL);
-	if (!ta)
+	if (!ta) {
+		inode->i_nlink--;
+		iput(inode);
 		return -ENOMEM;
+	}
 
 	ta->state = CREATE_1;
 	ta->ino = inode->i_ino;