bcachefs: fix error path of __bch2_read_super()
PATCH 1/1 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.
--- fs/bcachefs/super-io.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/bcachefs/super-io.c +4 -2
@@ -698,8 +698,10 @@ 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 ; + goto err; + }#ifndef __KERNEL__if (opt_get (*opts, direct_io) == false)
Signature · 1 line
2.40.1
Quoted 13 lines · Chao Yu
In
__bch2_read_super(), ifkstrdup()fails, it needs to release memory insb->holder, fix to callbch2_free_super()in the error path.Signed-off-by Chao Yu <[email protected]>--- fs/bcachefs/super-io.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)fs/bcachefs/super-io.c +0
-0
fs/bcachefs/super-io.c static int __bch2_read_super(const char *path, struct bch_opts *opts, · line 702
Quoted 7 lines
fs/bcachefs/super-io.c +2
-2@@ -698,8 +698,10 @@ 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 ;
maybe you should fill err with message info by prt_printf(xxx), because err with no message info when printed in bch2_print_opts.
Quoted 5 lines
fs/bcachefs/super-io.c +2
-0+ goto err; + }#ifndef __KERNEL__if (opt_get (*opts, direct_io) == false)
Quoted 11 lines · Hongbo Li
Quoted 8 lines · Chao Yu
In
__bch2_read_super(), ifkstrdup()fails, it needs to release memory insb->holder, fix to callbch2_free_super()in the error path.Signed-off-by Chao Yu <[email protected]>---
fs/bcachefs/super-io.c| 6 ++++--1 file changed, 4 insertions(+), 2 deletions(-)
Quoted 12 lines
fs/bcachefs/super-io.c static int __bch2_read_super(const char *path, struct bch_opts *opts, · line 701
Quoted 11 lines
fs/bcachefs/super-io.c +2
-2@@ -698,8 +698,10 @@ 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;maybe you should fill err with message info by
prt_printf(xxx), because err with no message info when printed inbch2_print_opts.
Oh, yes, will revise in v2, thank you for the comments.
Thanks,
Quoted 4 lines
Quoted 4 lines
fs/bcachefs/super-io.c +2
-0+ goto err; + } #ifndef __KERNEL__ if (opt_get(*opts, direct_io) == false)