提交 39e92e83 编写于 作者: K Kari Argillander 提交者: Zheng Zengkai

fs/ntfs3: Return straight without goto in fill_super

mainline inclusion
from mainline-v5.15
commit bce1828f
category: feature
bugzilla:
https://gitee.com/openeuler/kernel/issues/I4G67J?from=project-issue
CVE: NA

----------------------------------------------------------------------

In many places it is not needed to use goto out. We can just return
right away. This will make code little bit more cleaner as we won't
need to check error path.
Signed-off-by: NKari Argillander <kari.argillander@gmail.com>
Signed-off-by: NKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Signed-off-by: NYin Xiujiang <yinxiujiang@kylinos.cn>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NHou Tao <houtao1@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 21c394b4
...@@ -921,7 +921,7 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc) ...@@ -921,7 +921,7 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
err = ntfs_init_from_boot(sb, rq ? queue_logical_block_size(rq) : 512, err = ntfs_init_from_boot(sb, rq ? queue_logical_block_size(rq) : 512,
bd_inode->i_size); bd_inode->i_size);
if (err) if (err)
goto out; return err;
#ifdef CONFIG_NTFS3_64BIT_CLUSTER #ifdef CONFIG_NTFS3_64BIT_CLUSTER
sb->s_maxbytes = MAX_LFS_FILESIZE; sb->s_maxbytes = MAX_LFS_FILESIZE;
...@@ -937,10 +937,8 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc) ...@@ -937,10 +937,8 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
ref.seq = cpu_to_le16(MFT_REC_VOL); ref.seq = cpu_to_le16(MFT_REC_VOL);
inode = ntfs_iget5(sb, &ref, &NAME_VOLUME); inode = ntfs_iget5(sb, &ref, &NAME_VOLUME);
if (IS_ERR(inode)) { if (IS_ERR(inode)) {
err = PTR_ERR(inode);
ntfs_err(sb, "Failed to load $Volume."); ntfs_err(sb, "Failed to load $Volume.");
inode = NULL; return PTR_ERR(inode);
goto out;
} }
ni = ntfs_i(inode); ni = ntfs_i(inode);
...@@ -988,10 +986,8 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc) ...@@ -988,10 +986,8 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
ref.seq = cpu_to_le16(MFT_REC_MIRR); ref.seq = cpu_to_le16(MFT_REC_MIRR);
inode = ntfs_iget5(sb, &ref, &NAME_MIRROR); inode = ntfs_iget5(sb, &ref, &NAME_MIRROR);
if (IS_ERR(inode)) { if (IS_ERR(inode)) {
err = PTR_ERR(inode);
ntfs_err(sb, "Failed to load $MFTMirr."); ntfs_err(sb, "Failed to load $MFTMirr.");
inode = NULL; return PTR_ERR(inode);
goto out;
} }
sbi->mft.recs_mirr = sbi->mft.recs_mirr =
...@@ -1004,10 +1000,8 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc) ...@@ -1004,10 +1000,8 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
ref.seq = cpu_to_le16(MFT_REC_LOG); ref.seq = cpu_to_le16(MFT_REC_LOG);
inode = ntfs_iget5(sb, &ref, &NAME_LOGFILE); inode = ntfs_iget5(sb, &ref, &NAME_LOGFILE);
if (IS_ERR(inode)) { if (IS_ERR(inode)) {
err = PTR_ERR(inode);
ntfs_err(sb, "Failed to load \x24LogFile."); ntfs_err(sb, "Failed to load \x24LogFile.");
inode = NULL; return PTR_ERR(inode);
goto out;
} }
ni = ntfs_i(inode); ni = ntfs_i(inode);
...@@ -1025,16 +1019,14 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc) ...@@ -1025,16 +1019,14 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
if (!is_ro) { if (!is_ro) {
ntfs_warn(sb, ntfs_warn(sb,
"failed to replay log file. Can't mount rw!"); "failed to replay log file. Can't mount rw!");
err = -EINVAL; return -EINVAL;
goto out;
} }
} else if (sbi->volume.flags & VOLUME_FLAG_DIRTY) { } else if (sbi->volume.flags & VOLUME_FLAG_DIRTY) {
if (!is_ro && !sbi->options->force) { if (!is_ro && !sbi->options->force) {
ntfs_warn( ntfs_warn(
sb, sb,
"volume is dirty and \"force\" flag is not set!"); "volume is dirty and \"force\" flag is not set!");
err = -EINVAL; return -EINVAL;
goto out;
} }
} }
...@@ -1044,10 +1036,8 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc) ...@@ -1044,10 +1036,8 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
inode = ntfs_iget5(sb, &ref, &NAME_MFT); inode = ntfs_iget5(sb, &ref, &NAME_MFT);
if (IS_ERR(inode)) { if (IS_ERR(inode)) {
err = PTR_ERR(inode);
ntfs_err(sb, "Failed to load $MFT."); ntfs_err(sb, "Failed to load $MFT.");
inode = NULL; return PTR_ERR(inode);
goto out;
} }
ni = ntfs_i(inode); ni = ntfs_i(inode);
...@@ -1071,10 +1061,8 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc) ...@@ -1071,10 +1061,8 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
ref.seq = cpu_to_le16(MFT_REC_BADCLUST); ref.seq = cpu_to_le16(MFT_REC_BADCLUST);
inode = ntfs_iget5(sb, &ref, &NAME_BADCLUS); inode = ntfs_iget5(sb, &ref, &NAME_BADCLUS);
if (IS_ERR(inode)) { if (IS_ERR(inode)) {
err = PTR_ERR(inode);
ntfs_err(sb, "Failed to load $BadClus."); ntfs_err(sb, "Failed to load $BadClus.");
inode = NULL; return PTR_ERR(inode);
goto out;
} }
ni = ntfs_i(inode); ni = ntfs_i(inode);
...@@ -1096,10 +1084,8 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc) ...@@ -1096,10 +1084,8 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
ref.seq = cpu_to_le16(MFT_REC_BITMAP); ref.seq = cpu_to_le16(MFT_REC_BITMAP);
inode = ntfs_iget5(sb, &ref, &NAME_BITMAP); inode = ntfs_iget5(sb, &ref, &NAME_BITMAP);
if (IS_ERR(inode)) { if (IS_ERR(inode)) {
err = PTR_ERR(inode);
ntfs_err(sb, "Failed to load $Bitmap."); ntfs_err(sb, "Failed to load $Bitmap.");
inode = NULL; return PTR_ERR(inode);
goto out;
} }
ni = ntfs_i(inode); ni = ntfs_i(inode);
...@@ -1129,17 +1115,15 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc) ...@@ -1129,17 +1115,15 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
/* Compute the MFT zone. */ /* Compute the MFT zone. */
err = ntfs_refresh_zone(sbi); err = ntfs_refresh_zone(sbi);
if (err) if (err)
goto out; return err;
/* Load $AttrDef. */ /* Load $AttrDef. */
ref.low = cpu_to_le32(MFT_REC_ATTR); ref.low = cpu_to_le32(MFT_REC_ATTR);
ref.seq = cpu_to_le16(MFT_REC_ATTR); ref.seq = cpu_to_le16(MFT_REC_ATTR);
inode = ntfs_iget5(sbi->sb, &ref, &NAME_ATTRDEF); inode = ntfs_iget5(sbi->sb, &ref, &NAME_ATTRDEF);
if (IS_ERR(inode)) { if (IS_ERR(inode)) {
err = PTR_ERR(inode);
ntfs_err(sb, "Failed to load $AttrDef -> %d", err); ntfs_err(sb, "Failed to load $AttrDef -> %d", err);
inode = NULL; return PTR_ERR(inode);
goto out;
} }
if (inode->i_size < sizeof(struct ATTR_DEF_ENTRY)) { if (inode->i_size < sizeof(struct ATTR_DEF_ENTRY)) {
...@@ -1200,10 +1184,8 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc) ...@@ -1200,10 +1184,8 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
ref.seq = cpu_to_le16(MFT_REC_UPCASE); ref.seq = cpu_to_le16(MFT_REC_UPCASE);
inode = ntfs_iget5(sb, &ref, &NAME_UPCASE); inode = ntfs_iget5(sb, &ref, &NAME_UPCASE);
if (IS_ERR(inode)) { if (IS_ERR(inode)) {
err = PTR_ERR(inode);
ntfs_err(sb, "Failed to load $UpCase."); ntfs_err(sb, "Failed to load $UpCase.");
inode = NULL; return PTR_ERR(inode);
goto out;
} }
ni = ntfs_i(inode); ni = ntfs_i(inode);
...@@ -1249,7 +1231,7 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc) ...@@ -1249,7 +1231,7 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
/* Load $Secure. */ /* Load $Secure. */
err = ntfs_security_init(sbi); err = ntfs_security_init(sbi);
if (err) if (err)
goto out; return err;
/* Load $Extend. */ /* Load $Extend. */
err = ntfs_extend_init(sbi); err = ntfs_extend_init(sbi);
...@@ -1273,26 +1255,20 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc) ...@@ -1273,26 +1255,20 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
ref.seq = cpu_to_le16(MFT_REC_ROOT); ref.seq = cpu_to_le16(MFT_REC_ROOT);
inode = ntfs_iget5(sb, &ref, &NAME_ROOT); inode = ntfs_iget5(sb, &ref, &NAME_ROOT);
if (IS_ERR(inode)) { if (IS_ERR(inode)) {
err = PTR_ERR(inode);
ntfs_err(sb, "Failed to load root."); ntfs_err(sb, "Failed to load root.");
inode = NULL; return PTR_ERR(inode);
goto out;
} }
ni = ntfs_i(inode); ni = ntfs_i(inode);
sb->s_root = d_make_root(inode); sb->s_root = d_make_root(inode);
if (!sb->s_root)
if (!sb->s_root) { return -ENOMEM;
err = -ENOMEM;
goto out;
}
fc->fs_private = NULL; fc->fs_private = NULL;
fc->s_fs_info = NULL; fc->s_fs_info = NULL;
return 0; return 0;
out: out:
iput(inode); iput(inode);
return err; return err;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册