summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorYu Zhao <yuzhao@google.com>2018-09-19 23:30:51 +0200
committerMark Brown <broonie@kernel.org>2018-09-20 18:04:51 +0200
commitfb6de923ca3358a91525552b4907d4cb38730bdd (patch)
tree720cba8bacfb584d8a746769d08e9fa480dc317e /drivers
parentregulator: Fix 'do-nothing' value for regulators without suspend state (diff)
downloadlinux-fb6de923ca3358a91525552b4907d4cb38730bdd.tar.xz
linux-fb6de923ca3358a91525552b4907d4cb38730bdd.zip
regulator: fix crash caused by null driver data
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
Diffstat (limited to 'drivers')
-rw-r--r--drivers/regulator/core.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 90215f57270f..9577d8941846 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -4395,13 +4395,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 */