diff mbox series

[4/4] hypfs: free sb->s_fs_info after shutting down the super block

Message ID 20230831053157.256319-5-hch@lst.de (mailing list archive)
State Handled Elsewhere
Delegated to: Paul Moore
Headers show
Series [1/4] ramfs: free sb->s_fs_info after shutting down the super block | expand

Commit Message

Christoph Hellwig Aug. 31, 2023, 5:31 a.m. UTC
sb->s_fs_info can only be safely freed after generic_shutdown_super was
called and all access to the super_block has stopped.

Thus only free the private data after calling kill_litter_super, which
calls generic_shutdown_super internally.

Also remove the pointless clearing of sb->s_fs_info as the super_block
can't be accessed at this point and will be freed immediately.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 arch/s390/hypfs/inode.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Al Viro Aug. 31, 2023, 6:37 a.m. UTC | #1
On Thu, Aug 31, 2023 at 07:31:57AM +0200, Christoph Hellwig wrote:
> sb->s_fs_info can only be safely freed after generic_shutdown_super was
> called and all access to the super_block has stopped.
> 
> Thus only free the private data after calling kill_litter_super, which
> calls generic_shutdown_super internally.

Same as for ramfs.  We *do* use ->s_fs_info there, but only for
operations that require an active reference.  They can't overlap
with ->kill_sb().
diff mbox series

Patch

diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c
index ada83149932fec..dbe8a7dcafa922 100644
--- a/arch/s390/hypfs/inode.c
+++ b/arch/s390/hypfs/inode.c
@@ -329,9 +329,8 @@  static void hypfs_kill_super(struct super_block *sb)
 		hypfs_delete_tree(sb->s_root);
 	if (sb_info && sb_info->update_file)
 		hypfs_remove(sb_info->update_file);
-	kfree(sb->s_fs_info);
-	sb->s_fs_info = NULL;
 	kill_litter_super(sb);
+	kfree(sb->s_fs_info);
 }
 
 static struct dentry *hypfs_create_file(struct dentry *parent, const char *name,