xfs
[Top] [All Lists]

Re: [PATCH] xfs: fix memory leak in xfs_dir2_node_removename

To: Mark Tinguely <tinguely@xxxxxxx>
Subject: Re: [PATCH] xfs: fix memory leak in xfs_dir2_node_removename
From: Eric Sandeen <sandeen@xxxxxxxxxxx>
Date: Fri, 27 Sep 2013 11:44:21 -0500
Cc: xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <20130927130140.640252809@xxxxxxx>
References: <20130927130140.640252809@xxxxxxx>
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130801 Thunderbird/17.0.8
On 9/27/13 8:01 AM, Mark Tinguely wrote:
> Free the memory pointed to by state before returning on error from 
> xfs_dir2_node_removename.c
> 
> Signed-off-by: Mark Tinguely <tinguely@xxxxxxx>
> ---
> Found by Coverity (134681) in userspace, same patch applies there
> also.

Heh, looks like that one has been around since the dawn of time, thanks.

Reviewed-by: Eric Sandeen <sandeen@xxxxxxxxxx>

how do we handle the matching userspace fixes, separate patch to
be explicit?  Wait for the next syncup?

Thanks,
-Eric

>  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@xxxxxxxxxxx
> http://oss.sgi.com/mailman/listinfo/xfs
> 

<Prev in Thread] Current Thread [Next in Thread>