Message ID | 20230831053157.256319-4-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 |
On Thu, Aug 31, 2023 at 07:31:56AM +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, AFAICS. > Also remove the duplicate freeing in the sel_fill_super error path given > that ->kіll_sb is also called on ->fill_super failure. Reasonable cleanup, that.
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c index 9dafb6ff110d26..8a8a532be8e767 100644 --- a/security/selinux/selinuxfs.c +++ b/security/selinux/selinuxfs.c @@ -2100,9 +2100,6 @@ static int sel_fill_super(struct super_block *sb, struct fs_context *fc) err: pr_err("SELinux: %s: failed while creating inodes\n", __func__); - - selinux_fs_info_free(sb); - return ret; } @@ -2123,8 +2120,8 @@ static int sel_init_fs_context(struct fs_context *fc) static void sel_kill_sb(struct super_block *sb) { - selinux_fs_info_free(sb); kill_litter_super(sb); + selinux_fs_info_free(sb); } static struct file_system_type sel_fs_type = {
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 duplicate freeing in the sel_fill_super error path given that ->kіll_sb is also called on ->fill_super failure. Signed-off-by: Christoph Hellwig <hch@lst.de> --- security/selinux/selinuxfs.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)