[PATCH] hugetlbfs: release subpool on fill_super failure

From: Yichong Chen

Date: Sun Jul 19 2026 - 22:25:50 EST


hugetlbfs_fill_super() allocates a hugepage subpool when size or
min_size mount options are specified. hugepage_new_subpool() may also
reserve huge pages for min_size.

If root dentry creation fails after the subpool is created, the failure
path frees the subpool with kfree(). This bypasses
hugepage_put_subpool() and can leave min_size reservations charged.

Use hugepage_put_subpool() on the failure path, matching the normal
put_super path.

Fixes: 7ca02d0ae586 ("hugetlbfs: accept subpool min_size mount option and setup accordingly")
Signed-off-by: Yichong Chen <chenyichong@xxxxxxxxxxxxx>
---
fs/hugetlbfs/inode.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 216e1a0dd0b2..6a1d7e778cb0 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -1419,7 +1419,8 @@ hugetlbfs_fill_super(struct super_block *sb, struct fs_context *fc)
goto out_free;
return 0;
out_free:
- kfree(sbinfo->spool);
+ if (sbinfo->spool)
+ hugepage_put_subpool(sbinfo->spool);
kfree(sbinfo);
return -ENOMEM;
}
--
2.51.0