public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Ben Myers <bpm@sgi.com>
To: Eric Sandeen <sandeen@redhat.com>
Cc: xfs-oss <xfs@oss.sgi.com>
Subject: Re: [PATCH 1/3] xfs_repair: Fix fragmented multiblock dir2 handling in blkmap_getn()
Date: Thu, 31 May 2012 15:55:40 -0500	[thread overview]
Message-ID: <20120531205540.GI4721@sgi.com> (raw)
In-Reply-To: <4FBABD3E.2050700@redhat.com>

Hey Eric,

On Mon, May 21, 2012 at 05:10:06PM -0500, Eric Sandeen wrote:
> blkmap_getn() contains a loop which populates an array of extents
> with mapping information for a dir2 "block," which may consist
> of multiple filesystem blocks.
> 
> As written, the loop re-allocates the array for each new extent,
> leaking the previously allocated memory and worse, losing the
> previously filled-in extent information.
> 
> Fix this by only allocating the array once, for the maximum
> possible number of extents - the number of fs blocks in the dir
> block.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
> 
> diff --git a/repair/bmap.c b/repair/bmap.c
> index 2f1c307..c43ca7f 100644
> --- a/repair/bmap.c
> +++ b/repair/bmap.c
> @@ -168,7 +168,8 @@ blkmap_getn(
>  		/*
>  		 * rare case - multiple extents for a single dir block
>  		 */
> -		bmp = malloc(nb * sizeof(bmap_ext_t));
> +		if (!bmp)
> +			bmp = malloc(nb * sizeof(bmap_ext_t));

Cool.  That's an area where we don't have much test coverage.  I don't see a
single '-n size' in xfstests.

This looks good to me.  FWICS all the callers free it later.

Reviewed-by: Ben Myers <bpm@sgi.com>

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2012-05-31 20:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-21 22:07 [PATCH 0/3] xfs_repair fixes for fragmented multiblock v2 dirs Eric Sandeen
2012-05-21 22:10 ` [PATCH 1/3] xfs_repair: Fix fragmented multiblock dir2 handling in blkmap_getn() Eric Sandeen
2012-05-31 20:55   ` Ben Myers [this message]
2012-05-21 22:10 ` [PATCH 2/3] xfs_repair: Document & robustify blkmap_next_off() Eric Sandeen
2012-05-31 21:27   ` Ben Myers
2012-05-21 22:11 ` [PATCH 3/3] xfs_repair: handle fragmented multiblock dir2 in process_leaf_node_dir2() Eric Sandeen
2012-06-01 20:25   ` Ben Myers
2012-05-22  1:26 ` [PATCH 0/3] xfs_repair fixes for fragmented multiblock v2 dirs Eric Sandeen
2012-05-22 13:41 ` [PATCH 2/3 RESEND] " Eric Sandeen
2012-05-22 13:42 ` [PATCH 3/3 RESEND] xfs_repair: handle fragmented multiblock dir2 in process_leaf_node_dir2() 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=20120531205540.GI4721@sgi.com \
    --to=bpm@sgi.com \
    --cc=sandeen@redhat.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