From: David Sterba <dsterba@suse.cz>
To: Rakesh Pandit <rakesh@tuxera.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] Btrfs-progs: free path if we don't find root item
Date: Mon, 3 Mar 2014 19:02:42 +0100 [thread overview]
Message-ID: <20140303180242.GF7004@twin.jikos.cz> (raw)
In-Reply-To: <20140228172705.GA3536@localhost.localdomain>
On Fri, Feb 28, 2014 at 07:27:06PM +0200, Rakesh Pandit wrote:
> In btrfs_find_last_root before returning with -ENOENT (if root item is
> not found) free path and also remove btrfs_release_path before
> btrfs_free_path because btrfs_free_path anyway calls it.
>
> Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
> ---
> root-tree.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/root-tree.c b/root-tree.c
> index 858fe2f..f16f0ba 100644
> --- a/root-tree.c
> +++ b/root-tree.c
> @@ -40,8 +40,10 @@ int btrfs_find_last_root(struct btrfs_root *root, u64 objectid,
> ret = btrfs_search_slot(NULL, root, &search_key, path, 0, 0);
> if (ret < 0)
> goto out;
> - if (path->slots[0] == 0)
> + if (path->slots[0] == 0) {
> + btrfs_free_path(path);
I'll change it to
ret = -ENOENT;
goto out;
that's the pattern commonly used.
> return -ENOENT;
> + }
>
> BUG_ON(ret == 0);
> l = path->nodes[0];
> @@ -56,7 +58,6 @@ int btrfs_find_last_root(struct btrfs_root *root, u64 objectid,
> memcpy(key, &found_key, sizeof(found_key));
> ret = 0;
> out:
> - btrfs_release_path(path);
> btrfs_free_path(path);
> return ret;
> }
> @@ -120,7 +121,6 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
> write_extent_buffer(l, item, ptr, sizeof(*item));
> btrfs_mark_buffer_dirty(path->nodes[0]);
> out:
> - btrfs_release_path(path);
> btrfs_free_path(path);
> return ret;
> }
prev parent reply other threads:[~2014-03-03 18:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-28 17:27 [PATCH] Btrfs-progs: free path if we don't find root item Rakesh Pandit
2014-03-03 18:02 ` David Sterba [this message]
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=20140303180242.GF7004@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=rakesh@tuxera.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