From: Chao Yu <chao@kernel.org>
To: kent.overstreet@linux.dev, bfoster@redhat.com
Cc: linux-bcachefs@vger.kernel.org, Chao Yu <chao@kernel.org>
Subject: [PATCH] bcachefs: fix error path of __bch2_read_super()
Date: Thu, 11 Apr 2024 18:08:29 +0800 [thread overview]
Message-ID: <20240411100829.1729332-1-chao@kernel.org> (raw)
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>
---
fs/bcachefs/super-io.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c
index ad28e370b640..cec1470c2dd9 100644
--- a/fs/bcachefs/super-io.c
+++ b/fs/bcachefs/super-io.c
@@ -698,8 +698,10 @@ 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;
+ goto err;
+ }
#ifndef __KERNEL__
if (opt_get(*opts, direct_io) == false)
--
2.40.1
next reply other threads:[~2024-04-11 10:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-11 10:08 Chao Yu [this message]
2024-04-11 11:29 ` [PATCH] bcachefs: fix error path of __bch2_read_super() Hongbo Li
2024-04-12 6:32 ` Chao Yu
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=20240411100829.1729332-1-chao@kernel.org \
--to=chao@kernel.org \
--cc=bfoster@redhat.com \
--cc=kent.overstreet@linux.dev \
--cc=linux-bcachefs@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).