Commit 251b9c21 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mark Brown

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: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent 5e01dc7b
...@@ -139,6 +139,7 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np) ...@@ -139,6 +139,7 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np)
struct property *prop; struct property *prop;
const char *regtype; const char *regtype;
int proplen, gpio, i; int proplen, gpio, i;
int ret;
config = devm_kzalloc(dev, config = devm_kzalloc(dev,
sizeof(struct gpio_regulator_config), sizeof(struct gpio_regulator_config),
...@@ -202,7 +203,11 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np) ...@@ -202,7 +203,11 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np)
} }
config->nr_states = i; 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)) if (!strncmp("voltage", regtype, 7))
config->type = REGULATOR_VOLTAGE; config->type = REGULATOR_VOLTAGE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment