[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250917144844.e8d9b9593aac9f3a4b52a0cb@linux-foundation.org>
Date: Wed, 17 Sep 2025 14:48:44 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Donet Tom <donettom@...ux.ibm.com>
Cc: Chris Mason <clm@...a.com>, David Hildenbrand <david@...hat.com>, Oscar
Salvador <osalvador@...e.de>, Zi Yan <ziy@...dia.com>, Greg Kroah-Hartman
<gregkh@...uxfoundation.org>, Ritesh Harjani <ritesh.list@...il.com>,
linux-mm@...ck.org, linux-kernel@...r.kernel.org, "Rafael J . Wysocki"
<rafael@...nel.org>, Danilo Krummrich <dakr@...nel.org>, Jonathan Cameron
<Jonathan.Cameron@...wei.com>, Alison Schofield
<alison.schofield@...el.com>, Yury Norov <yury.norov@...il.com>, Dave Jiang
<dave.jiang@...el.com>, KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
Subject: Re: [PATCH v2] drivers/base/node: Handle error properly in
register_one_node()
On Wed, 17 Sep 2025 20:25:48 +0530 Donet Tom <donettom@...ux.ibm.com> wrote:
> > Can this cause a double-free? Looking at register_node(), when
> > device_register() fails, it calls put_device(&node->dev). The put_device()
> > call triggers node_device_release() which does kfree(to_node(dev)), freeing
> > the entire node structure. So when register_node() returns an error, the
> > node memory is already freed, but this code calls kfree(node) again on the
> > same memory.
> >
> > The call chain is: register_node()->device_register() fails->
> > put_device()->node_device_release()->kfree(to_node(dev)).
>
>
> Thank you for pointing this out. I will address it and send a v3.
This patch is now in mm.git's non-rebasing mm-stable branch, so no
replacements, please.
A standalone patch with
Fixes: 786eb990cfb7 ("drivers/base/node: handle error properly in register_one_node()")
is the way to go.
Powered by blists - more mailing lists