lkml.org 
[lkml]   [2023]   [Sep]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
Subject[PATCH 1/2] regulator/core: regulator_register: set device->class earlier
From
device_initialize() calls for the `device` struct be freed with
`put_device()`. This requires a release() callback that is provided by
the regulator_class.

Fixes: d3c731564e09 ("regulator: plug of_node leak in regulator_register()'s error path")
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
drivers/regulator/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index d8e1caaf207e..2f6ee5527cb0 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -5542,6 +5542,7 @@ regulator_register(struct device *dev,
goto rinse;
}
device_initialize(&rdev->dev);
+ rdev->dev.class = &regulator_class;
spin_lock_init(&rdev->err_lock);

/*
@@ -5603,7 +5604,6 @@ regulator_register(struct device *dev,
rdev->supply_name = regulator_desc->supply_name;

/* register with sysfs */
- rdev->dev.class = &regulator_class;
rdev->dev.parent = config->dev;
dev_set_name(&rdev->dev, "regulator.%lu",
(unsigned long) atomic_inc_return(&regulator_no));
--
2.39.2
\
 
 \ /
  Last update: 2023-09-17 23:37    [W:0.046 / U:0.208 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site