mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-08 14:13:53 +00:00
regulator/core: regulator_register: set device->class earlier
When fixing a memory leak in commitd3c731564e
("regulator: plug of_node leak in regulator_register()'s error path") it moved the device_initialize() call earlier, but did not move the `dev->class` initialization. The bug was spotted and fixed by reverting part of the commit (in commit5f4b204b6b
"regulator: core: fix kobject release warning and memory leak in regulator_register()") but introducing a different bug: now early error paths use `kfree(dev)` instead of `put_device()` for an already initialized `struct device`. Move the missing assignments to just after `device_initialize()`. Fixes:d3c731564e
("regulator: plug of_node leak in regulator_register()'s error path") Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> Link: https://lore.kernel.org/r/b5b19cb458c40c9d02f3d5a7bd1ba7d97ba17279.1695077303.git.mirq-linux@rere.qmqm.pl Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
7e37c85137
commit
8adb4e647a
@ -5542,6 +5542,8 @@ regulator_register(struct device *dev,
|
||||
goto rinse;
|
||||
}
|
||||
device_initialize(&rdev->dev);
|
||||
dev_set_drvdata(&rdev->dev, rdev);
|
||||
rdev->dev.class = ®ulator_class;
|
||||
spin_lock_init(&rdev->err_lock);
|
||||
|
||||
/*
|
||||
@ -5603,11 +5605,9 @@ 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));
|
||||
dev_set_drvdata(&rdev->dev, rdev);
|
||||
|
||||
/* set regulator constraints */
|
||||
if (init_data)
|
||||
|
Loading…
Reference in New Issue
Block a user