Skip to content

Commit 275dca4

Browse files
committed
f2fs: move release of block devices to after kill_block_super()
Call destroy_device_list() and free the f2fs_sb_info from kill_f2fs_super(), after the call to kill_block_super(). This is necessary to order it after the call to fscrypt_destroy_keyring() once generic_shutdown_super() starts calling fscrypt_destroy_keyring() just after calling ->put_super. This is because fscrypt_destroy_keyring() may call into f2fs_get_devices() via the fscrypt_operations. Reviewed-by: Chao Yu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Eric Biggers <[email protected]>
1 parent c1f1f5b commit 275dca4

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

fs/f2fs/super.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,12 +1717,10 @@ static void f2fs_put_super(struct super_block *sb)
17171717

17181718
kvfree(sbi->ckpt);
17191719

1720-
sb->s_fs_info = NULL;
17211720
if (sbi->s_chksum_driver)
17221721
crypto_free_shash(sbi->s_chksum_driver);
17231722
kfree(sbi->raw_super);
17241723

1725-
destroy_device_list(sbi);
17261724
f2fs_destroy_page_array_cache(sbi);
17271725
f2fs_destroy_xattr_caches(sbi);
17281726
mempool_destroy(sbi->write_io_dummy);
@@ -1738,7 +1736,6 @@ static void f2fs_put_super(struct super_block *sb)
17381736
#if IS_ENABLED(CONFIG_UNICODE)
17391737
utf8_unload(sb->s_encoding);
17401738
#endif
1741-
kfree(sbi);
17421739
}
17431740

17441741
int f2fs_sync_fs(struct super_block *sb, int sync)
@@ -4902,9 +4899,9 @@ static struct dentry *f2fs_mount(struct file_system_type *fs_type, int flags,
49024899

49034900
static void kill_f2fs_super(struct super_block *sb)
49044901
{
4905-
if (sb->s_root) {
4906-
struct f2fs_sb_info *sbi = F2FS_SB(sb);
4902+
struct f2fs_sb_info *sbi = F2FS_SB(sb);
49074903

4904+
if (sb->s_root) {
49084905
set_sbi_flag(sbi, SBI_IS_CLOSE);
49094906
f2fs_stop_gc_thread(sbi);
49104907
f2fs_stop_discard_thread(sbi);
@@ -4931,6 +4928,12 @@ static void kill_f2fs_super(struct super_block *sb)
49314928
sb->s_flags &= ~SB_RDONLY;
49324929
}
49334930
kill_block_super(sb);
4931+
/* Release block devices last, after fscrypt_destroy_keyring(). */
4932+
if (sbi) {
4933+
destroy_device_list(sbi);
4934+
kfree(sbi);
4935+
sb->s_fs_info = NULL;
4936+
}
49344937
}
49354938

49364939
static struct file_system_type f2fs_fs_type = {

0 commit comments

Comments
 (0)