From: Hongbo Li <lihongbo22@huawei.com>
To: Chao Yu <chao@kernel.org>,
Kent Overstreet <kent.overstreet@linux.dev>,
Brian Foster <bfoster@redhat.com>
Cc: <linux-bcachefs@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] bcachefs: fix error path of __bch2_read_super()
Date: Fri, 12 Apr 2024 14:53:00 +0800 [thread overview]
Message-ID: <9ed2e6d6-186c-4b89-9c07-4b004de6bf23@huawei.com> (raw)
In-Reply-To: <20240412063638.2068524-1-chao@kernel.org>
Reviewed-by: Hongbo Li <lihongbo22@huawei.com>
On 2024/4/12 14:36, Chao Yu wrote:
> In __bch2_read_super(), if kstrdup() fails, it needs to release memory
> in sb->holder, fix to call bch2_free_super() in the error path.
>
> Signed-off-by: Chao Yu <chao@kernel.org>
> ---
> v2:
> - add error message in error path pointed out by Hongbo Li.
> fs/bcachefs/super-io.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c
> index ad28e370b640..cc80d7d30b8c 100644
> --- a/fs/bcachefs/super-io.c
> +++ b/fs/bcachefs/super-io.c
> @@ -698,8 +698,11 @@ static int __bch2_read_super(const char *path, struct bch_opts *opts,
> return -ENOMEM;
>
> sb->sb_name = kstrdup(path, GFP_KERNEL);
> - if (!sb->sb_name)
> - return -ENOMEM;
> + if (!sb->sb_name) {
> + ret = -ENOMEM;
> + prt_printf(&err, "error allocating memory for sb_name");
> + goto err;
> + }
>
> #ifndef __KERNEL__
> if (opt_get(*opts, direct_io) == false)
next prev parent reply other threads:[~2024-04-12 6:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-12 6:36 Chao Yu
2024-04-12 6:53 ` Hongbo Li [this message]
2024-04-15 2:03 ` Hongbo Li
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=9ed2e6d6-186c-4b89-9c07-4b004de6bf23@huawei.com \
--to=lihongbo22@huawei.com \
--cc=bfoster@redhat.com \
--cc=chao@kernel.org \
--cc=kent.overstreet@linux.dev \
--cc=linux-bcachefs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®