summaryrefslogtreecommitdiff
path: root/drivers/regulator
diff options
context:
space:
mode:
authorDong Aisheng <aisheng.dong@nxp.com>2017-04-14 22:32:43 +0800
committerMark Brown <broonie@kernel.org>2017-04-14 18:09:26 +0100
commit4af5924c02818ca170bb6902dbb883687b969aeb (patch)
tree6bf18fe423a1a175cc831b97eaaaa4996b3ec186 /drivers/regulator
parent9bf944548169f6153c3d3778cf983cb5db251a0e (diff)
regulator: anatop: make sure regulator name is properly defined
For anatop regulator we must have a name accordingly. Make sure the name is properly checked before using it to avoid a possible kernel NULL point crash. Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/anatop-regulator.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c
index fa27c9de6744..606f3fa6de62 100644
--- a/drivers/regulator/anatop-regulator.c
+++ b/drivers/regulator/anatop-regulator.c
@@ -198,6 +198,10 @@ static int anatop_regulator_probe(struct platform_device *pdev)
rdesc->owner = THIS_MODULE;
of_property_read_string(np, "regulator-name", &rdesc->name);
+ if (!rdesc->name) {
+ dev_err(dev, "failed to get a regulator-name\n");
+ return -EINVAL;
+ }
initdata = of_get_regulator_init_data(dev, np, rdesc);
if (!initdata)
@@ -300,8 +304,7 @@ static int anatop_regulator_probe(struct platform_device *pdev)
sreg->sel = 22;
/* set the default voltage of the pcie phy to be 1.100v */
- if (!sreg->sel && rdesc->name &&
- !strcmp(rdesc->name, "vddpcie"))
+ if (!sreg->sel && !strcmp(rdesc->name, "vddpcie"))
sreg->sel = 0x10;
if (!sreg->bypass && !sreg->sel) {