From: Andrew Morton <akpm@linux-foundation.org>
To: Yichong Chen <chenyichong@uniontech.com>
Cc: Muchun Song <muchun.song@linux.dev>,
Oscar Salvador <osalvador@suse.de>,
David Hildenbrand <david@kernel.org>,
Mike Kravetz <mike.kravetz@oracle.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] hugetlbfs: release subpool on fill_super failure
Date: Sun, 19 Jul 2026 22:54:38 -0700 [thread overview]
Message-ID: <20260719225438.041287a56c87effe61796483@linux-foundation.org> (raw)
In-Reply-To: <20260720021900.1376309-1-chenyichong@uniontech.com>
On Mon, 20 Jul 2026 10:18:59 +0800 Yichong Chen <chenyichong@uniontech.com> wrote:
> 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.
lgtm, thanks.
This might have led AI review to find a pre-existing bug in
mm/hugetlb.c:unlock_or_release_subpool():
https://sashiko.dev/#/patchset/20260720021900.1376309-1-chenyichong@uniontech.com
> --- 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);
Both callers of hugepage_put_subpool do this NULL check. We could move
that check into hugepage_put_subpool().
> kfree(sbinfo);
> return -ENOMEM;
> }
next prev parent reply other threads:[~2026-07-20 5:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 2:18 Yichong Chen
2026-07-20 5:54 ` Andrew Morton [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260719225438.041287a56c87effe61796483@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=chenyichong@uniontech.com \
--cc=david@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=muchun.song@linux.dev \
--cc=osalvador@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®