Skip to content

Commit 7b0b133

Browse files
josephhztorvalds
authored andcommitted
ocfs2: fix crash when initialize filecheck kobj fails
Once s_root is set, genric_shutdown_super() will be called if fill_super() fails. That means, we will call ocfs2_dismount_volume() twice in such case, which can lead to kernel crash. Fix this issue by initializing filecheck kobj before setting s_root. Link: https://lkml.kernel.org/r/20220310081930.86305-1-joseph.qi@linux.alibaba.com Fixes: 5f483c4 ("ocfs2: add kobject for online file check") Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com> Cc: Mark Fasheh <mark@fasheh.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Junxiao Bi <junxiao.bi@oracle.com> Cc: Changwei Ge <gechangwei@live.cn> Cc: Gang He <ghe@suse.com> Cc: Jun Piao <piaojun@huawei.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 8208257 commit 7b0b133

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

fs/ocfs2/super.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,17 +1105,6 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
11051105
goto read_super_error;
11061106
}
11071107

1108-
root = d_make_root(inode);
1109-
if (!root) {
1110-
status = -ENOMEM;
1111-
mlog_errno(status);
1112-
goto read_super_error;
1113-
}
1114-
1115-
sb->s_root = root;
1116-
1117-
ocfs2_complete_mount_recovery(osb);
1118-
11191108
osb->osb_dev_kset = kset_create_and_add(sb->s_id, NULL,
11201109
&ocfs2_kset->kobj);
11211110
if (!osb->osb_dev_kset) {
@@ -1133,6 +1122,17 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
11331122
goto read_super_error;
11341123
}
11351124

1125+
root = d_make_root(inode);
1126+
if (!root) {
1127+
status = -ENOMEM;
1128+
mlog_errno(status);
1129+
goto read_super_error;
1130+
}
1131+
1132+
sb->s_root = root;
1133+
1134+
ocfs2_complete_mount_recovery(osb);
1135+
11361136
if (ocfs2_mount_local(osb))
11371137
snprintf(nodestr, sizeof(nodestr), "local");
11381138
else

0 commit comments

Comments
 (0)