Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hugetlbfs: release subpool on fill_super failure
@ 2026-07-20  2:18 Yichong Chen
  2026-07-20  5:54 ` Andrew Morton
  0 siblings, 1 reply; 5+ messages in thread
From: Yichong Chen @ 2026-07-20  2:18 UTC (permalink / raw)
  To: Muchun Song, Oscar Salvador
  Cc: David Hildenbrand, Andrew Morton, Mike Kravetz, linux-mm,
	linux-kernel, Yichong Chen

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@uniontech.com>
---
 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



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-07-21  3:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-20  2:18 [PATCH] hugetlbfs: release subpool on fill_super failure Yichong Chen
2026-07-20  5:54 ` Andrew Morton
2026-07-20  7:19   ` Yichong Chen
2026-07-20  7:38   ` [PATCH] hugetlb: make hugepage_put_subpool() tolerate NULL Yichong Chen
2026-07-21  3:02     ` Muchun Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox