Commit 3a8c9208 authored by Mark Tinguely's avatar Mark Tinguely Committed by Ben Myers

xfs: fix memory leak in xfs_dir2_node_removename

Fix the leak of kernel memory in xfs_dir2_node_removename()
when xfs_dir2_leafn_remove() returns an error code.
Signed-off-by: default avatarMark Tinguely <tinguely@sgi.com>
Reviewed-by: default avatarBen Myers <bpm@sgi.com>
Signed-off-by: default avatarBen Myers <bpm@sgi.com>

(cherry picked from commit ef701600)
parent f94c4457
...@@ -2067,12 +2067,12 @@ xfs_dir2_node_lookup( ...@@ -2067,12 +2067,12 @@ xfs_dir2_node_lookup(
*/ */
int /* error */ int /* error */
xfs_dir2_node_removename( xfs_dir2_node_removename(
xfs_da_args_t *args) /* operation arguments */ struct xfs_da_args *args) /* operation arguments */
{ {
xfs_da_state_blk_t *blk; /* leaf block */ struct xfs_da_state_blk *blk; /* leaf block */
int error; /* error return value */ int error; /* error return value */
int rval; /* operation return value */ int rval; /* operation return value */
xfs_da_state_t *state; /* btree cursor */ struct xfs_da_state *state; /* btree cursor */
trace_xfs_dir2_node_removename(args); trace_xfs_dir2_node_removename(args);
...@@ -2084,19 +2084,18 @@ xfs_dir2_node_removename( ...@@ -2084,19 +2084,18 @@ xfs_dir2_node_removename(
state->mp = args->dp->i_mount; state->mp = args->dp->i_mount;
state->blocksize = state->mp->m_dirblksize; state->blocksize = state->mp->m_dirblksize;
state->node_ents = state->mp->m_dir_node_ents; state->node_ents = state->mp->m_dir_node_ents;
/*
* Look up the entry we're deleting, set up the cursor. /* Look up the entry we're deleting, set up the cursor. */
*/
error = xfs_da3_node_lookup_int(state, &rval); error = xfs_da3_node_lookup_int(state, &rval);
if (error) if (error)
rval = error; goto out_free;
/*
* Didn't find it, upper layer screwed up. /* Didn't find it, upper layer screwed up. */
*/
if (rval != EEXIST) { if (rval != EEXIST) {
xfs_da_state_free(state); error = rval;
return rval; goto out_free;
} }
blk = &state->path.blk[state->path.active - 1]; blk = &state->path.blk[state->path.active - 1];
ASSERT(blk->magic == XFS_DIR2_LEAFN_MAGIC); ASSERT(blk->magic == XFS_DIR2_LEAFN_MAGIC);
ASSERT(state->extravalid); ASSERT(state->extravalid);
...@@ -2107,7 +2106,7 @@ xfs_dir2_node_removename( ...@@ -2107,7 +2106,7 @@ xfs_dir2_node_removename(
error = xfs_dir2_leafn_remove(args, blk->bp, blk->index, error = xfs_dir2_leafn_remove(args, blk->bp, blk->index,
&state->extrablk, &rval); &state->extrablk, &rval);
if (error) if (error)
return error; goto out_free;
/* /*
* Fix the hash values up the btree. * Fix the hash values up the btree.
*/ */
...@@ -2122,6 +2121,7 @@ xfs_dir2_node_removename( ...@@ -2122,6 +2121,7 @@ xfs_dir2_node_removename(
*/ */
if (!error) if (!error)
error = xfs_dir2_node_to_leaf(state); error = xfs_dir2_node_to_leaf(state);
out_free:
xfs_da_state_free(state); xfs_da_state_free(state);
return error; return error;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment