Commit 3078e059 authored by Chao Yu's avatar Chao Yu Committed by Kent Overstreet

bcachefs: fix error path of __bch2_read_super()

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: default avatarChao Yu <chao@kernel.org>
Reviewed-by: default avatarHongbo Li <lihongbo22@huawei.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent f0a73d4f
......@@ -700,8 +700,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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment