summaryrefslogtreecommitdiffstats
path: root/drivers/regulator/gpio-regulator.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>2013-11-09 13:12:28 +0100
committerMark Brown <broonie@linaro.org>2013-11-09 15:06:22 +0000
commit251b9c21d26ca9d210e7673f0819ee1f6c19402a (patch)
tree94fc2dea8cb5df0789fcaa9bb4b65f466a3dd8c1 /drivers/regulator/gpio-regulator.c
parent5e01dc7b26d9f24f39abace5da98ccbd6a5ceb52 (diff)
downloadlinux-stable-251b9c21d26ca9d210e7673f0819ee1f6c19402a.tar.gz
linux-stable-251b9c21d26ca9d210e7673f0819ee1f6c19402a.tar.bz2
linux-stable-251b9c21d26ca9d210e7673f0819ee1f6c19402a.zip
regulator: gpio-regulator: Don't oops on missing regulator-type property
Catch missing regulator-type property in DT and return an error gracefully instead of deferencing a NULL pointer and crashing. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/regulator/gpio-regulator.c')
-rw-r--r--drivers/regulator/gpio-regulator.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c
index 98a98ffa7fe0..bcd827c363dc 100644
--- a/drivers/regulator/gpio-regulator.c
+++ b/drivers/regulator/gpio-regulator.c
@@ -139,6 +139,7 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np)
struct property *prop;
const char *regtype;
int proplen, gpio, i;
+ int ret;
config = devm_kzalloc(dev,
sizeof(struct gpio_regulator_config),
@@ -202,7 +203,11 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np)
}
config->nr_states = i;
- of_property_read_string(np, "regulator-type", &regtype);
+ ret = of_property_read_string(np, "regulator-type", &regtype);
+ if (ret < 0) {
+ dev_err(dev, "Missing 'regulator-type' property\n");
+ return ERR_PTR(-EINVAL);
+ }
if (!strncmp("voltage", regtype, 7))
config->type = REGULATOR_VOLTAGE;