mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 13:55:32 +00:00
regulator: fix crash caused by null driver data
commit fb6de923ca
upstream.
dev_set_drvdata() needs to be called before device_register()
exposes device to userspace. Otherwise kernel crashes after it
gets null pointer from dev_get_drvdata() when userspace tries
to access sysfs entries.
[Removed backtrace for length -- broonie]
Signed-off-by: Yu Zhao <yuzhao@google.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
b6adc1f24b
commit
5eaaa5e9bd
1 changed files with 1 additions and 1 deletions
|
@ -4115,13 +4115,13 @@ regulator_register(const struct regulator_desc *regulator_desc,
|
|||
!rdev->desc->fixed_uV)
|
||||
rdev->is_switch = true;
|
||||
|
||||
dev_set_drvdata(&rdev->dev, rdev);
|
||||
ret = device_register(&rdev->dev);
|
||||
if (ret != 0) {
|
||||
put_device(&rdev->dev);
|
||||
goto unset_supplies;
|
||||
}
|
||||
|
||||
dev_set_drvdata(&rdev->dev, rdev);
|
||||
rdev_init_debugfs(rdev);
|
||||
|
||||
/* try to resolve regulators supply since a new one was registered */
|
||||
|
|
Loading…
Reference in a new issue