ocfs2: iput inode alloc when failed locally
authorjiangyiwen <jiangyiwen@huawei.com>
Thu, 3 Apr 2014 21:47:12 +0000 (14:47 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 3 Apr 2014 23:20:57 +0000 (16:20 -0700)
In ocfs2_info_handle_freeinode() and ocfs2_test_inode_bit() func, after
calls ocfs2_get_system_file_inode() to get inode ref, if calls
ocfs2_info_scan_inode_alloc() or ocfs2_inode_lock() failed, we should
iput inode alloc to avoid leaking the inode.

Signed-off-by: jiangyiwen <jiangyiwen@huawei.com>
Reviewed-by: Joseph Qi <joseph.qi@huawei.com>
Cc: Mark Fasheh <mfasheh@suse.de>
Cc: Joel Becker <jlbec@evilplan.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/ocfs2/ioctl.c
fs/ocfs2/suballoc.c

index 8ca3c29accbf08f2d7d40aaf53afcee6563a7322..490229f43731caae647d091eb6425479db871636 100644 (file)
@@ -413,11 +413,12 @@ int ocfs2_info_handle_freeinode(struct inode *inode,
                }
 
                status = ocfs2_info_scan_inode_alloc(osb, inode_alloc, blkno, oifi, i);
-               if (status < 0)
-                       goto bail;
 
                iput(inode_alloc);
                inode_alloc = NULL;
+
+               if (status < 0)
+                       goto bail;
        }
 
        o2info_set_request_filled(&oifi->ifi_req);
index 94fb1f3d9e624b6e147096989987881421c0064c..0cb889a17ae14db8ffc7e0688543be132a126ea6 100644 (file)
@@ -2894,6 +2894,7 @@ int ocfs2_test_inode_bit(struct ocfs2_super *osb, u64 blkno, int *res)
        status = ocfs2_inode_lock(inode_alloc_inode, &alloc_bh, 0);
        if (status < 0) {
                mutex_unlock(&inode_alloc_inode->i_mutex);
+               iput(inode_alloc_inode);
                mlog(ML_ERROR, "lock on alloc inode on slot %u failed %d\n",
                     (u32)suballoc_slot, status);
                goto bail;