[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b44ef13c-c9df-5d08-f92f-649fef9d74ee@intel.com>
Date: Wed, 17 Aug 2022 17:41:39 +0800
From: "Yin, Fengwei" <fengwei.yin@...el.com>
To: Miaohe Lin <linmiaohe@...wei.com>, <akpm@...ux-foundation.org>,
<mike.kravetz@...cle.com>, <songmuchun@...edance.com>
CC: <linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 5/6] mm/hugetlb: fix sysfs group leak in
hugetlb_unregister_node()
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;
}
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;
> + }
> }
Powered by blists - more mailing lists