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: Chao Yu <chao@kernel.org>
Reviewed-by: Hongbo Li <lihongbo22@huawei.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Chao Yu 2024-04-12 14:36:38 +08:00 committed by Kent Overstreet
parent f0a73d4fde
commit 3078e059a5
1 changed files with 5 additions and 2 deletions

View File

@ -700,8 +700,11 @@ retry:
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)