mm/hugetlb: fix WARN_ON(!kobj) in sysfs_create_group()
authorMiaohe Lin <linmiaohe@huawei.com>
Tue, 16 Aug 2022 13:05:49 +0000 (21:05 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 12 Sep 2022 03:25:55 +0000 (20:25 -0700)
commit3a6bdda0b58bab883da8dc3a0503e2a13b9d7456
treeb252d9fa19e82c65e87357021b5288b8cf3807b7
parenta43a83c79b4fd36e297f97b7468be28fdf771d78
mm/hugetlb: fix WARN_ON(!kobj) in sysfs_create_group()

If sysfs_create_group() fails with hstate_attr_group, hstate_kobjs[hi]
will be set to NULL.  Then it will be passed to sysfs_create_group() if
h->demote_order != 0 thus triggering WARN_ON(!kobj) check.  Fix this by
making sure hstate_kobjs[hi] != NULL when calling sysfs_create_group.

Link: https://lkml.kernel.org/r/20220816130553.31406-3-linmiaohe@huawei.com
Fixes: 79dfc695525f ("hugetlb: add demote hugetlb page sysfs interfaces")
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
Reviewed-by: Muchun Song <songmuchun@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/hugetlb.c