projects
/
openwrt
/
staging
/
blogic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
5e01dc7
)
regulator: gpio-regulator: Don't oops on missing regulator-type property
author
Laurent Pinchart
<
[email protected]
>
Sat, 9 Nov 2013 12:12:28 +0000
(13:12 +0100)
committer
Mark Brown
<
[email protected]
>
Sat, 9 Nov 2013 15:06:22 +0000
(15:06 +0000)
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 <
[email protected]
>
Signed-off-by: Mark Brown <
[email protected]
>
drivers/regulator/gpio-regulator.c
patch
|
blob
|
history
diff --git
a/drivers/regulator/gpio-regulator.c
b/drivers/regulator/gpio-regulator.c
index 98a98ffa7fe07d2bcb23f2c9cad593b416aaf203..bcd827c363dc7b85353ab39509dcf42816b01ddb 100644
(file)
--- 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", ®type);
+ ret = of_property_read_string(np, "regulator-type", ®type);
+ if (ret < 0) {
+ dev_err(dev, "Missing 'regulator-type' property\n");
+ return ERR_PTR(-EINVAL);
+ }
if (!strncmp("voltage", regtype, 7))
config->type = REGULATOR_VOLTAGE;