On 8/17/2022 5:41 PM, Yin, Fengwei wrote: > Hi Miaohe, > > On 8/16/2022 9:05 PM, Miaohe Lin wrote: >> } >> >> if (h->demote_order) { >> - if (sysfs_create_group(hstate_kobjs[hi], >> - &hstate_demote_attr_group)) >> + retval = sysfs_create_group(hstate_kobjs[hi], >> + &hstate_demote_attr_group); > What about add one more: > just return if hstate_attr_group creating failed: > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index 0aee2f3ae15c..a67ef4b4eb3f 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -3845,6 +3845,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; > } Please ignore this. Just saw the patch 2 made this change. Regards Yin, Fengwei > > Once hstate_kobjs[hi] is set to NULL, hstate_demote_attr_group creating will > fail as well. Thanks. > > > Regards > Yin, Fengwei > >> + if (retval) { >> pr_warn("HugeTLB unable to create demote interfaces for %s\n", h->name); >> + sysfs_remove_group(hstate_kobjs[hi], hstate_attr_group); >> + kobject_put(hstate_kobjs[hi]); >> + hstate_kobjs[hi] = NULL; >> + return retval; >> + } >> } >