[PATCH v2] node: put_device after failing to device_register

Zhi Song posted 1 patch 3 years, 10 months ago
There is a newer version of this series
drivers/base/node.c | 1 +
1 file changed, 1 insertion(+)
[PATCH v2] node: put_device after failing to device_register
Posted by Zhi Song 3 years, 10 months ago
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.

Signed-off-by: Zhi Song <zhi.song@bytedance.com>
---
Fix the changelog text correct.
---
 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