[PATCH 1/2] regulator/core: regulator_register: set device->class earlier
From: Michał Mirosław
Date: Sun Sep 17 2023 - 17:41:31 EST
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@xxxxxxxxxxxx>
---
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 = ®ulator_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 = ®ulator_class;
rdev->dev.parent = config->dev;
dev_set_name(&rdev->dev, "regulator.%lu",
(unsigned long) atomic_inc_return(®ulator_no));
--
2.39.2