From: Muchun Song <smuchun@gmail.com>
To: Miaohe Lin <linmiaohe@huawei.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
mike.kravetz@oracle.com, linux-mm@kvack.org,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mm/hugetlb: Fix potential double free in hugetlb_register_node() error path
Date: Sat, 9 Jan 2021 12:36:24 +0800 [thread overview]
Message-ID: <CAPSr9jGE_vYAdnWDMskywtp3B_qpC_caZ0_azecTnmZuJ-A1=w@mail.gmail.com> (raw)
In-Reply-To: <20210107123249.36964-1-linmiaohe@huawei.com>
On Thu, Jan 7, 2021 at 8:36 PM Miaohe Lin <linmiaohe@huawei.com> wrote:
>
> In hugetlb_sysfs_add_hstate(), we would do kobject_put() on hstate_kobjs
> when failed to create sysfs group but forget to set hstate_kobjs to NULL.
> Then in hugetlb_register_node() error path, we may free it again via
> hugetlb_unregister_node().
>
> Fixes: a3437870160c ("hugetlb: new sysfs interface")
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> Cc: <stable@vger.kernel.org>
> ---
> mm/hugetlb.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
Reviewed-by: Muchun Song <smuchun@gmail.com>
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index e249bffa0e75..91a2a2025a2c 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -2947,8 +2947,10 @@ static int hugetlb_sysfs_add_hstate(struct hstate *h, struct kobject *parent,
> return -ENOMEM;
>
> retval = sysfs_create_group(hstate_kobjs[hi], hstate_attr_group);
> - if (retval)
> + if (retval) {
> kobject_put(hstate_kobjs[hi]);
> + hstate_kobjs[hi] = NULL;
> + }
>
> return retval;
> }
> --
> 2.19.1
>
prev parent reply other threads:[~2021-01-09 4:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-07 12:32 Miaohe Lin
2021-01-07 19:59 ` Mike Kravetz
2021-01-07 23:15 ` Andrew Morton
2021-01-08 1:41 ` Miaohe Lin
2021-01-09 4:36 ` Muchun Song [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='CAPSr9jGE_vYAdnWDMskywtp3B_qpC_caZ0_azecTnmZuJ-A1=w@mail.gmail.com' \
--to=smuchun@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.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