regulator: fix crash caused by null driver data
authorYu Zhao <yuzhao@google.com>
Wed, 19 Sep 2018 21:30:51 +0000 (15:30 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 4 Oct 2018 00:00:55 +0000 (17:00 -0700)
commit5eaaa5e9bd56813deef7afd5b70f2d62f51187f4
tree20e0b35b1358d947b8286df941a58f6fe7c17da0
parentb6adc1f24bb356c5601391b79ea689f06a55a17f
regulator: fix crash caused by null driver data

commit fb6de923ca3358a91525552b4907d4cb38730bdd 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>
drivers/regulator/core.c