summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs
diff options
context:
space:
mode:
authorChao Yu <chao@kernel.org>2024-04-12 08:36:38 +0200
committerKent Overstreet <kent.overstreet@linux.dev>2024-04-15 19:31:15 +0200
commit3078e059a5e984663c5c2b04485375c84c2700f9 (patch)
treeac15378e83c7da7c6143427915a74fb76f549c04 /fs/bcachefs
parentbcachefs: Check for backpointer bucket_offset >= bucket size (diff)
downloadlinux-3078e059a5e984663c5c2b04485375c84c2700f9.tar.xz
linux-3078e059a5e984663c5c2b04485375c84c2700f9.zip
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>
Diffstat (limited to 'fs/bcachefs')
-rw-r--r--fs/bcachefs/super-io.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c
index e0aa3655b63b..648986a7dbde 100644
--- a/fs/bcachefs/super-io.c
+++ b/fs/bcachefs/super-io.c
@@ -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)