]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bcachefs: fix error path of __bch2_read_super()
authorChao Yu <chao@kernel.org>
Fri, 12 Apr 2024 06:36:38 +0000 (14:36 +0800)
committerKent Overstreet <kent.overstreet@linux.dev>
Mon, 15 Apr 2024 17:31:15 +0000 (13:31 -0400)
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>
fs/bcachefs/super-io.c

index e0aa3655b63b4cd7ca8dd2ee03e0370474427ab3..648986a7dbdeeb00c7df5c422300a0e9278d89ee 100644 (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)