[PATCH] xfs: fix memory leak in xfs_dir2_node_removename
Roger Willcocks
roger at filmlight.ltd.uk
Fri Sep 27 14:36:13 CDT 2013
On Fri, 2013-09-27 at 08:01 -0500, Mark Tinguely wrote:
> plain text document attachment
> (xfs-fix-leak-in-xfs_dir2_node_removename.patch)
> Free the memory pointed to by state before returning on error from
> xfs_dir2_node_removename.c
>
> Signed-off-by: Mark Tinguely <tinguely at sgi.com>
> ---
> Found by Coverity (134681) in userspace, same patch applies there
> also.
>
Is the first hunk right ?
xfs_da_node_lookup_int called as
error = xfs_da_node_lookup_int(state, &rval);
and returns with
*result = retval;
return(0);
so, on return, error == 0 and rval == an error code. The next lines:
if (error)
rval = error;
won't change that. But previously if rval != EEXIST you returned rval.
With the change below, you return error, which is zero.
--
Roger
> fs/xfs/xfs_dir2_node.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> Index: b/fs/xfs/xfs_dir2_node.c
> ===================================================================
> --- a/fs/xfs/xfs_dir2_node.c
> +++ b/fs/xfs/xfs_dir2_node.c
> @@ -2131,10 +2131,9 @@ xfs_dir2_node_removename(
> /*
> * Didn't find it, upper layer screwed up.
> */
> - if (rval != EEXIST) {
> - xfs_da_state_free(state);
> - return rval;
> - }
> + if (rval != EEXIST)
> + goto done;
> +
> blk = &state->path.blk[state->path.active - 1];
> ASSERT(blk->magic == XFS_DIR2_LEAFN_MAGIC);
> ASSERT(state->extravalid);
> @@ -2145,7 +2144,7 @@ xfs_dir2_node_removename(
> error = xfs_dir2_leafn_remove(args, blk->bp, blk->index,
> &state->extrablk, &rval);
> if (error)
> - return error;
> + goto done;
> /*
> * Fix the hash values up the btree.
> */
> @@ -2160,6 +2159,7 @@ xfs_dir2_node_removename(
> */
> if (!error)
> error = xfs_dir2_node_to_leaf(state);
> +done:
> xfs_da_state_free(state);
> return error;
> }
>
>
> _______________________________________________
> xfs mailing list
> xfs at oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
>
--
Roger Willcocks <roger at filmlight.ltd.uk>
More information about the xfs
mailing list