Skip to content

Commit 3078e05

Browse files
chaseyuKent Overstreet
authored andcommitted
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 <[email protected]> Reviewed-by: Hongbo Li <[email protected]> Signed-off-by: Kent Overstreet <[email protected]>
1 parent f0a73d4 commit 3078e05

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

fs/bcachefs/super-io.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,8 +700,11 @@ static int __bch2_read_super(const char *path, struct bch_opts *opts,
700700
return -ENOMEM;
701701

702702
sb->sb_name = kstrdup(path, GFP_KERNEL);
703-
if (!sb->sb_name)
704-
return -ENOMEM;
703+
if (!sb->sb_name) {
704+
ret = -ENOMEM;
705+
prt_printf(&err, "error allocating memory for sb_name");
706+
goto err;
707+
}
705708

706709
#ifndef __KERNEL__
707710
if (opt_get(*opts, direct_io) == false)

0 commit comments

Comments
 (0)