Both callers of hugepage_put_subpool() check whether the subpool pointer is NULL before calling it. Move the NULL check into hugepage_put_subpool() so callers can use the helper unconditionally. This is a follow-up cleanup after using hugepage_put_subpool() from the hugetlbfs_fill_super() failure path. Signed-off-by: Yichong Chen --- fs/hugetlbfs/inode.c | 6 ++---- mm/hugetlb.c | 3 +++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 6a1d7e778cb0..0c125eda16fd 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -1129,8 +1129,7 @@ static void hugetlbfs_put_super(struct super_block *sb) if (sbi) { sb->s_fs_info = NULL; - if (sbi->spool) - hugepage_put_subpool(sbi->spool); + hugepage_put_subpool(sbi->spool); kfree(sbi); } @@ -1419,8 +1418,7 @@ hugetlbfs_fill_super(struct super_block *sb, struct fs_context *fc) goto out_free; return 0; out_free: - if (sbinfo->spool) - hugepage_put_subpool(sbinfo->spool); + hugepage_put_subpool(sbinfo->spool); kfree(sbinfo); return -ENOMEM; } diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 571212b80835..e319c6a00555 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -181,6 +181,9 @@ void hugepage_put_subpool(struct hugepage_subpool *spool) { unsigned long flags; + if (!spool) + return; + spin_lock_irqsave(&spool->lock, flags); BUG_ON(!spool->count); spool->count--; -- 2.51.0