Skip to content

Commit

Permalink
ocfs2: fix inode leak
Browse files Browse the repository at this point in the history
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 <mark.fasheh@oracle.com>
  • Loading branch information
Mark Fasheh committed May 25, 2007
1 parent 5c3c6bb commit 8fccfc8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions fs/ocfs2/localalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8fccfc8

Please sign in to comment.