fix leak in __logfs_create()
authorAl Viro <viro@zeniv.linux.org.uk>
Sun, 4 Jul 2010 08:23:11 +0000 (12:23 +0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Mon, 9 Aug 2010 20:47:28 +0000 (16:47 -0400)
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>
fs/logfs/dir.c

index 72d1893ddd360ccf144cf962c4e2f05f9a136638..675cc49197feb177bcb67e0f0aefa66deed9cabd 100644 (file)
@@ -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;