mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drivers/base/node: Fix cleanup path of node_init_node_access()
@ 2026-09-17  6:28 Li Ming
  0 siblings, 0 replies; only message in thread
From: Li Ming @ 2026-09-17  6:28 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Keith Busch, Jonathan Cameron
  Cc: Rafael J. Wysocki, driver-core, linux-kernel, Li Ming

In node_init_node_access(), it frees the device when device_register()
fails. But per the description of device_register(), should use
put_device() to give up the device reference when device_register()
fails, rather than freeing the device directly.

Fixes: 08d9dbe72b1f ("node: Link memory nodes to their compute nodes")
Signed-off-by: Li Ming <ming.li@zohomail.com>
---
 drivers/base/node.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/base/node.c b/drivers/base/node.c
index 3da91929ad4e..dcdc8626627a 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -167,20 +167,19 @@ static struct node_access_nodes *node_init_node_access(struct node *node,
 	dev->parent = &node->dev;
 	dev->release = node_access_release;
 	dev->groups = node_access_node_groups;
-	if (dev_set_name(dev, "access%u", access))
-		goto free;
+	if (dev_set_name(dev, "access%u", access)) {
+		kfree(access_node);
+		return NULL;
+	}
 
-	if (device_register(dev))
-		goto free_name;
+	if (device_register(dev)) {
+		put_device(dev);
+		return NULL;
+	}
 
 	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);
-free:
-	kfree(access_node);
-	return NULL;
 }
 
 #ifdef CONFIG_HMEM_REPORTING

---
base-commit: fd73f4a6659897191fa0d40695fe370925dd3780
change-id: 20260917-fix_cleanup_patch_of_node_init_node_access-5d9572693b2a

Best regards,
-- 
Li Ming <ming.li@zohomail.com>


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-17  6:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-17  6:28 [PATCH] drivers/base/node: Fix cleanup path of node_init_node_access() Li Ming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®