Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=8fccfc829a66b8b879c6672940523a402a786ce1
Commit:     8fccfc829a66b8b879c6672940523a402a786ce1
Parent:     5c3c6bb7709bf2bf4132750124879b3d89183e46
Author:     Mark Fasheh <[EMAIL PROTECTED]>
AuthorDate: Wed May 9 17:34:26 2007 -0700
Committer:  Mark Fasheh <[EMAIL PROTECTED]>
CommitDate: Fri May 25 11:00:46 2007 -0700

    ocfs2: fix inode leak
    
    We weren't cleaning up our inode reference on error in
    ocfs2_reserve_local_alloc_bits(). Add a check for error return and iput() if
    need be. Move the code to set the alloc context inode info to the end of the
    function so we don't have any possibility of passing back a bad pointer.
    
    Signed-off-by: Mark Fasheh <[EMAIL PROTECTED]>
---
 fs/ocfs2/localalloc.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index 4dedd97..545f789 100644
--- a/fs/ocfs2/localalloc.c
+++ b/fs/ocfs2/localalloc.c
@@ -471,9 +471,6 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb,
 
        mutex_lock(&local_alloc_inode->i_mutex);
 
-       ac->ac_inode = local_alloc_inode;
-       ac->ac_which = OCFS2_AC_USE_LOCAL;
-
        if (osb->local_alloc_state != OCFS2_LA_ENABLED) {
                status = -ENOSPC;
                goto bail;
@@ -511,10 +508,14 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super 
*osb,
                }
        }
 
+       ac->ac_inode = local_alloc_inode;
+       ac->ac_which = OCFS2_AC_USE_LOCAL;
        get_bh(osb->local_alloc_bh);
        ac->ac_bh = osb->local_alloc_bh;
        status = 0;
 bail:
+       if (status < 0 && local_alloc_inode)
+               iput(local_alloc_inode);
 
        mlog_exit(status);
        return status;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to