diff options
author | 2022-08-16 21:05:49 +0800 | |
---|---|---|
committer | 2022-09-11 20:25:55 -0700 | |
commit | 3a6bdda0b58bab883da8dc3a0503e2a13b9d7456 (patch) | |
tree | b252d9fa19e82c65e87357021b5288b8cf3807b7 /mm | |
parent | mm/hugetlb: fix incorrect update of max_huge_pages (diff) | |
download | linux-3a6bdda0b58bab883da8dc3a0503e2a13b9d7456.tar.gz linux-3a6bdda0b58bab883da8dc3a0503e2a13b9d7456.tar.bz2 linux-3a6bdda0b58bab883da8dc3a0503e2a13b9d7456.zip |
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>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/hugetlb.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index e72052964fb5..ff991e5bdf1f 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3846,6 +3846,7 @@ static int hugetlb_sysfs_add_hstate(struct hstate *h, struct kobject *parent, if (retval) { kobject_put(hstate_kobjs[hi]); hstate_kobjs[hi] = NULL; + return retval; } if (h->demote_order) { |