From: Dave Chinner <david@fromorbit.com>
To: Mark Tinguely <tinguely@sgi.com>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 1/2] xfs: fix memory leak in xfs_dir2_node_removename
Date: Thu, 3 Oct 2013 06:32:41 +1000 [thread overview]
Message-ID: <20131002203241.GV12541@dastard> (raw)
In-Reply-To: <20131002125409.826742020@sgi.com>
On Wed, Oct 02, 2013 at 07:51:11AM -0500, Mark Tinguely wrote:
> Fix the leak of kernel memory in xfs_dir2_node_removename()
> when xfs_dir2_leafn_remove() returns an error code.
>
> Found by Coverity in userspace same patch applies there also.
>
> Signed-off-by: Mark Tinguely <tinguely@sgi.com>
> ---
> v2 corrected bad return code as pointed out by Roger Willcocks.
>
> fs/xfs/xfs_dir2_node.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> Index: b/fs/xfs/xfs_dir2_node.c
> ===================================================================
> --- a/fs/xfs/xfs_dir2_node.c
> +++ b/fs/xfs/xfs_dir2_node.c
> @@ -2105,12 +2105,12 @@ xfs_dir2_node_lookup(
> */
> int /* error */
> 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 rval; /* operation return value */
> - xfs_da_state_t *state; /* btree cursor */
> + struct xfs_da_state *state; /* btree cursor */
>
> trace_xfs_dir2_node_removename(args);
>
> @@ -2132,9 +2132,10 @@ xfs_dir2_node_removename(
> * Didn't find it, upper layer screwed up.
> */
> if (rval != EEXIST) {
> - xfs_da_state_free(state);
> - return rval;
> + error = rval;
> + goto done;
Can you make this something like "out_free"? We tend to name jump
labels according to the action that needs to be taken, like
"out_unlock", "error_trans_cancel", etc...
Also, this code is now "funky" in how it handles rval. it will do
this:
/*
* Look up the entry we're deleting, set up the cursor.
*/
error = xfs_da3_node_lookup_int(state, &rval);
if (error)
rval = error;
/*
* Didn't find it, upper layer screwed up.
*/
if (rval != EEXIST) {
error = rval;
goto out_free;
}
That's kind funky with the reassignment of rval if there's an error.
Better would be:
/* Look up the entry we're deleting, set up the cursor. */
error = xfs_da3_node_lookup_int(state, &rval);
if (error)
goto out_free;
/* Didn't find it, upper layer screwed up. */
if (rval != EEXIST) {
error = rval;
goto out_free;
}
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2013-10-02 20:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-02 12:51 [PATCH 0/2] misc kernel leak patches Mark Tinguely
2013-10-02 12:51 ` [PATCH 1/2] xfs: fix memory leak in xfs_dir2_node_removename Mark Tinguely
2013-10-02 20:32 ` Dave Chinner [this message]
2013-10-02 21:04 ` Mark Tinguely
2013-10-02 12:51 ` [PATCH 2/2] xfs free the list of recovery items on error Mark Tinguely
2013-12-04 20:51 ` Ben Myers
2013-12-05 22:52 ` Ben Myers
2013-10-02 20:54 ` [PATCH 0/2] misc kernel leak patches Eric Sandeen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131002203241.GV12541@dastard \
--to=david@fromorbit.com \
--cc=tinguely@sgi.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox