Skip to content

Commit

Permalink
ocfs2: fix crash when initialize filecheck kobj fails
Browse files Browse the repository at this point in the history
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/[email protected]
Fixes: 5f483c4 ("ocfs2: add kobject for online file check")
Signed-off-by: Joseph Qi <[email protected]>
Cc: Mark Fasheh <[email protected]>
Cc: Joel Becker <[email protected]>
Cc: Junxiao Bi <[email protected]>
Cc: Changwei Ge <[email protected]>
Cc: Gang He <[email protected]>
Cc: Jun Piao <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
josephhz authored and torvalds committed Mar 17, 2022
1 parent 8208257 commit 7b0b133
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions fs/ocfs2/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1105,17 +1105,6 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
goto read_super_error;
}

root = d_make_root(inode);
if (!root) {
status = -ENOMEM;
mlog_errno(status);
goto read_super_error;
}

sb->s_root = root;

ocfs2_complete_mount_recovery(osb);

osb->osb_dev_kset = kset_create_and_add(sb->s_id, NULL,
&ocfs2_kset->kobj);
if (!osb->osb_dev_kset) {
Expand All @@ -1133,6 +1122,17 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
goto read_super_error;
}

root = d_make_root(inode);
if (!root) {
status = -ENOMEM;
mlog_errno(status);
goto read_super_error;
}

sb->s_root = root;

ocfs2_complete_mount_recovery(osb);

if (ocfs2_mount_local(osb))
snprintf(nodestr, sizeof(nodestr), "local");
else
Expand Down

0 comments on commit 7b0b133

Please sign in to comment.