diff mbox series

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

Message ID 20230831053157.256319-3-hch@lst.de (mailing list archive)
State New, archived
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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/devpts/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Al Viro Aug. 31, 2023, 6:31 a.m. UTC | #1
On Thu, Aug 31, 2023 at 07:31:55AM +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.

Similar to ramfs case; nothing in dentry/inode eviction codepaths is
using anything in ->s_fs_info.  And references in tty are holding
an active ref to superblock in question, preventing ->kill_sb(), so
nothing from the outside is going to play with e.g. devpts_{new,kill}_index()
under us.
diff mbox series

Patch

diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index 299c295a27a03e..d46cea36c026ad 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -491,10 +491,10 @@  static void devpts_kill_sb(struct super_block *sb)
 {
 	struct pts_fs_info *fsi = DEVPTS_SB(sb);
 
+	kill_litter_super(sb);
 	if (fsi)
 		ida_destroy(&fsi->allocated_ptys);
 	kfree(fsi);
-	kill_litter_super(sb);
 }
 
 static struct file_system_type devpts_fs_type = {