diff mbox

btrfs: handle errors returned from get_tree_block_key

Message ID 1366822294-9193-1-git-send-email-dsterba@suse.cz (mailing list archive)
State New, archived
Headers show

Commit Message

David Sterba April 24, 2013, 4:51 p.m. UTC
Signed-off-by: David Sterba <dsterba@suse.cz>
---
 fs/btrfs/relocation.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Zach Brown April 25, 2013, 10:18 p.m. UTC | #1
On Wed, Apr 24, 2013 at 06:51:34PM +0200, David Sterba wrote:
> Signed-off-by: David Sterba <dsterba@suse.cz>
> ---
>  fs/btrfs/relocation.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index c22ccfe..e85be23 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -2878,8 +2878,11 @@ int relocate_tree_blocks(struct btrfs_trans_handle *trans,
>  	rb_node = rb_first(blocks);
>  	while (rb_node) {
>  		block = rb_entry(rb_node, struct tree_block, rb_node);
> -		if (!block->key_ready)
> -			get_tree_block_key(rc, block);
> +		if (!block->key_ready) {
> +			err = get_tree_block_key(rc, block);
> +			if (err)
> +				goto out_path;
> +		}

Doesn't this leak the path?  Whoever named that label out_path was
having a laugh :).

		btrfs_free_path(path);
	out_path:
		free_block_list(blocks);
		return err;
	}

- z
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index c22ccfe..e85be23 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -2878,8 +2878,11 @@  int relocate_tree_blocks(struct btrfs_trans_handle *trans,
 	rb_node = rb_first(blocks);
 	while (rb_node) {
 		block = rb_entry(rb_node, struct tree_block, rb_node);
-		if (!block->key_ready)
-			get_tree_block_key(rc, block);
+		if (!block->key_ready) {
+			err = get_tree_block_key(rc, block);
+			if (err)
+				goto out_path;
+		}
 		rb_node = rb_next(rb_node);
 	}