mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3] node: put_device after failing to device_register
@ 2022-06-15 15:17 Zhi Song
  2022-06-20 13:55 ` Johan Hovold
  0 siblings, 1 reply; 4+ messages in thread
From: Zhi Song @ 2022-06-15 15:17 UTC (permalink / raw)
  To: gregkh, rafael; +Cc: linux-kernel, Zhi Song

device_register() is used to register a device with the system.
We need to call put_device() to give up the reference initialized
in device_register() when it returns an error and this will clean
up correctly.

Fixes: 08d9dbe72b1f ("node: Link memory nodes to their compute nodes")
Signed-off-by: Zhi Song <zhi.song@bytedance.com>
---
V1 -> V2: Fix up the changelog text correct.
V2 -> V3: Add a fixes tag line specifying the commit where this bug was
introduced.
---
 drivers/base/node.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/base/node.c b/drivers/base/node.c
index 0ac6376ef7a1..88a3337c546e 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -154,6 +154,7 @@ static struct node_access_nodes *node_init_node_access(struct node *node,
 	list_add_tail(&access_node->list_node, &node->access_list);
 	return access_node;
 free_name:
+	put_device(dev);
 	kfree_const(dev->kobj.name);
 free:
 	kfree(access_node);
-- 
2.30.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-06-21 12:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-15 15:17 [PATCH v3] node: put_device after failing to device_register Zhi Song
2022-06-20 13:55 ` Johan Hovold
     [not found]   ` <1D7A6F9F-9069-4D87-A493-7DB1BDA1EDB4@bytedance.com>
2022-06-21  7:04     ` Johan Hovold
     [not found]   ` <C6760D95-B26F-47AE-A8F6-F80129135A6C@bytedance.com>
2022-06-21 12:03     ` Johan Hovold

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®