linux/fs/efivarfs
Breno Leitao 816d369734 efivarfs: Fix memory leak of efivarfs_fs_info in fs_context error paths
[ Upstream commit 64e135f1ea ]

When processing mount options, efivarfs allocates efivarfs_fs_info (sfi)
early in fs_context initialization. However, sfi is associated with the
superblock and typically freed when the superblock is destroyed. If the
fs_context is released (final put) before fill_super is called—such as
on error paths or during reconfiguration—the sfi structure would leak,
as ownership never transfers to the superblock.

Implement the .free callback in efivarfs_context_ops to ensure any
allocated sfi is properly freed if the fs_context is torn down before
fill_super, preventing this memory leak.

Suggested-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Fixes: 5329aa5101 ("efivarfs: Add uid/gid mount options")
Signed-off-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2025-07-24 08:56:36 +02:00
..
file.c [tree-wide] finally take no_llseek out 2024-09-27 08:18:43 -07:00
inode.c efivarfs: Fix error on non-existent file 2024-12-27 14:02:07 +01:00
internal.h efivarfs: Fix error on non-existent file 2024-12-27 14:02:07 +01:00
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
Makefile efi: vars: Move efivar caching layer into efivarfs 2022-06-24 20:40:19 +02:00
super.c efivarfs: Fix memory leak of efivarfs_fs_info in fs_context error paths 2025-07-24 08:56:36 +02:00
vars.c efi: Clear up misconceptions about a maximum variable name size 2024-04-13 10:33:02 +02:00