* [PATCH] drivers/base/node: fix UAF on device_register() failure
@ 2026-08-06 8:28 Linkai Gong
2026-08-06 21:53 ` Danilo Krummrich
0 siblings, 1 reply; 2+ messages in thread
From: Linkai Gong @ 2026-08-06 8:28 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J . Wysocki, Danilo Krummrich
Cc: Jonathan Cameron, Keith Busch, driver-core, linux-kernel,
Linkai Gong
node_init_node_access() frees the access node with kfree() if
device_register() fails. After device_register() the embedded device is
initialized and must be released with put_device() so that
node_access_release() can free it.
Use the same put_device error path style as node_init_cache_dev().
Fixes: 08d9dbe72b1f ("node: Link memory nodes to their compute nodes")
Signed-off-by: Linkai Gong <gonglinkai@kylinos.cn>
---
drivers/base/node.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/base/node.c b/drivers/base/node.c
index 3da91929ad4e..d2fd57c2edc8 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -176,8 +176,10 @@ static struct node_access_nodes *node_init_node_access(struct node *node,
pm_runtime_no_callbacks(dev);
list_add_tail(&access_node->list_node, &node->access_list);
return access_node;
+
free_name:
- kfree_const(dev->kobj.name);
+ put_device(dev);
+ return NULL;
free:
kfree(access_node);
return NULL;
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drivers/base/node: fix UAF on device_register() failure
2026-08-06 8:28 [PATCH] drivers/base/node: fix UAF on device_register() failure Linkai Gong
@ 2026-08-06 21:53 ` Danilo Krummrich
0 siblings, 0 replies; 2+ messages in thread
From: Danilo Krummrich @ 2026-08-06 21:53 UTC (permalink / raw)
To: Linkai Gong
Cc: Greg Kroah-Hartman, Rafael J . Wysocki, Jonathan Cameron,
Keith Busch, driver-core, linux-kernel
On Thu Aug 6, 2026 at 10:28 AM CEST, Linkai Gong wrote:
> diff --git a/drivers/base/node.c b/drivers/base/node.c
> index 3da91929ad4e..d2fd57c2edc8 100644
> --- a/drivers/base/node.c
> +++ b/drivers/base/node.c
> @@ -176,8 +176,10 @@ static struct node_access_nodes *node_init_node_access(struct node *node,
> pm_runtime_no_callbacks(dev);
> list_add_tail(&access_node->list_node, &node->access_list);
> return access_node;
> +
> free_name:
> - kfree_const(dev->kobj.name);
> + put_device(dev);
> + return NULL;
Good catch, but we should also rename the label; free_name is misleading.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-06 21:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-06 8:28 [PATCH] drivers/base/node: fix UAF on device_register() failure Linkai Gong
2026-08-06 21:53 ` Danilo Krummrich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox