mm/hugeltb: handle the error case in hugetlb_fix_reserve_counts()
authorMiaohe Lin <linmiaohe@huawei.com>
Wed, 5 May 2021 01:34:38 +0000 (18:34 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 22 May 2021 08:40:31 +0000 (10:40 +0200)
commit5e9562fabb47f1395547edfde35018045b1b0a2b
treedea483e343e01937a0f73071e682ee929bcf5e6b
parentd5e95afdd84931b2c41b24a7ac41899d87aab297
mm/hugeltb: handle the error case in hugetlb_fix_reserve_counts()

[ Upstream commit da56388c4397878a65b74f7fe97760f5aa7d316b ]

A rare out of memory error would prevent removal of the reserve map region
for a page.  hugetlb_fix_reserve_counts() handles this rare case to avoid
dangling with incorrect counts.  Unfortunately, hugepage_subpool_get_pages
and hugetlb_acct_memory could possibly fail too.  We should correctly
handle these cases.

Link: https://lkml.kernel.org/r/20210410072348.20437-5-linmiaohe@huawei.com
Fixes: b5cec28d36f5 ("hugetlbfs: truncate_hugepages() takes a range of pages")
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Cc: Feilong Lin <linfeilong@huawei.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
mm/hugetlb.c