From: Lance Yang <lance.yang@linux.dev>
To: Guangshuo Li <lgs201920130244@gmail.com>,
"David Hildenbrand (Arm)" <david@kernel.org>
Cc: stable@vger.kernel.org,
"Liam R. Howlett" <Liam.Howlett@oracle.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Barry Song <baohua@kernel.org>, Nico Pache <npache@redhat.com>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
Dev Jain <dev.jain@arm.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Ryan Roberts <ryan.roberts@arm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Zi Yan <ziy@nvidia.com>
Subject: Re: [PATCH v2] mm: thp: Fix refcount leak in thpsize_create() error path
Date: Mon, 13 Apr 2026 22:13:23 +0800 [thread overview]
Message-ID: <8747df25-721f-4813-b81d-8c7275a2f33b@linux.dev> (raw)
In-Reply-To: <8eda3f8b-b811-4303-aefb-4b23aeeff16c@kernel.org>
On 2026/4/13 19:39, David Hildenbrand (Arm) wrote:
[...]
>> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
>> index 40cf59301c21..c8ffa188a198 100644
>> --- a/mm/huge_memory.c
>> +++ b/mm/huge_memory.c
>> @@ -726,10 +726,8 @@ static struct thpsize *thpsize_create(int order, struct kobject *parent)
>>
>> ret = kobject_init_and_add(&thpsize->kobj, &thpsize_ktype, parent,
>> "hugepages-%lukB", size);
>> - if (ret) {
>> - kfree(thpsize);
>> + if (ret)
>> goto err;
>> - }
>
> kobject_init_and_add() indeed documents "If this function returns an
> error, kobject_put() must be called".
>
> As Andrew says, that's not what the "goto err" does.
Right. v1[1] should do the trick: just jump to err_put
- if (ret) {
- kfree(thpsize);
- goto err;
- }
-
+ if (ret)
+ goto err_put;
Hmm... not sure why this changed to "goto err"
[1]
https://lore.kernel.org/linux-mm/20260411062152.2092967-1-lgs201920130244@gmail.com/#t
prev parent reply other threads:[~2026-04-13 14:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-12 17:54 Guangshuo Li
2026-04-12 18:35 ` Andrew Morton
2026-04-13 11:39 ` David Hildenbrand (Arm)
2026-04-13 14:13 ` Lance Yang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8747df25-721f-4813-b81d-8c7275a2f33b@linux.dev \
--to=lance.yang@linux.dev \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=lgs201920130244@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=npache@redhat.com \
--cc=ryan.roberts@arm.com \
--cc=stable@vger.kernel.org \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox