Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DC3E415F17; Sat, 12 Sep 2026 08:38:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789202323; cv=none; b=AklQjYsC+InH2OMvZ2RaGRob52Uz7mR7lx8roBM3yZjy1Ou/ofFRepaGg+0PKvbR+twWFqGWD/ICaANdC1O+pG4PmIbEpuGbrqkM79fwXZ54o1aeSemISQy3sTWLJfjUD2ss9+iX7CKjMaGraUHbsby/v+kbTWjp7BL63NbSZTY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789202323; c=relaxed/simple; bh=0MZGHUwEMhHQeWPH+G+gv3lzkkQTbdkZ4z98hI5ZCTs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uQje/RyjQH6qiacdmVFC3v1QIwG8iUo0NZHvkjRgfgOm1yYoV0p/bXZoW8rhHNAJ/DNSc8o6rjAbzBPaLz4RTr1Paqi64G+UzgC/ioD1lRANJauoEivz1/eczJP1w7OKMrq7ZTi9oBqC1iaRBJTDWzTn6KKEdPrIL3Llix6nNa4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=LOKNWZms; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="LOKNWZms" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 624E61F000FF; Sat, 12 Sep 2026 08:38:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789202322; bh=W679ujNSOzH81lEy1w7lHi6lagIjjzZuvQ+uzWS5thY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LOKNWZms5WSOQgtc7XDRbMlT52FV+NigegLecvWj6tLPUmwKa9CYwyWT2PC4SDz1+ 6ong0KlM2OusZmS1c1Twfh7Jfvpa6jiV1Dn4AGgIz1yhbZvguFyvC9tON7sM184wki Tu0R6ZujNhQrzJo7fpW4BDJxZw15lI62x669S6xs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yichong Chen , David Hildenbrand , Muchun Song , Oscar Salvador , Andrew Morton , Sasha Levin Subject: [PATCH 7.2 1178/1815] hugetlbfs: release subpool on fill_super failure Date: Sat, 12 Sep 2026 08:48:48 +0200 Message-ID: <20260912065716.669568403@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065648.999753832@linuxfoundation.org> References: <20260912065648.999753832@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yichong Chen [ Upstream commit 308ab73e97c87bd0e142b11758faab7f88d82854 ] 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. Link: https://lore.kernel.org/20260720021900.1376309-1-chenyichong@uniontech.com Fixes: 7ca02d0ae586 ("hugetlbfs: accept subpool min_size mount option and setup accordingly") Signed-off-by: Yichong Chen Cc: David Hildenbrand Cc: Muchun Song Cc: Oscar Salvador Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin --- 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 216e1a0dd0b23..6a1d7e778cb0e 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.53.0