[1/2] regulator/core: regulator_register: set device->class earlier
Commit Message
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(-)
@@ -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));