* [PATCH] regulator: gpio-regulator: Don't oops on missing regulator-type property
@ 2013-11-09 12:12 Laurent Pinchart
2013-11-09 15:07 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Laurent Pinchart @ 2013-11-09 12:12 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown; +Cc: linux-sh, linux-kernel
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>
---
drivers/regulator/gpio-regulator.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c
index 98a98ff..bcd827c 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", ®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;
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] regulator: gpio-regulator: Don't oops on missing regulator-type property
2013-11-09 12:12 [PATCH] regulator: gpio-regulator: Don't oops on missing regulator-type property Laurent Pinchart
@ 2013-11-09 15:07 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2013-11-09 15:07 UTC (permalink / raw)
To: Laurent Pinchart; +Cc: Liam Girdwood, linux-sh, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 215 bytes --]
On Sat, Nov 09, 2013 at 01:12:28PM +0100, Laurent Pinchart wrote:
> Catch missing regulator-type property in DT and return an error
> gracefully instead of deferencing a NULL pointer and crashing.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-11-09 15:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-09 12:12 [PATCH] regulator: gpio-regulator: Don't oops on missing regulator-type property Laurent Pinchart
2013-11-09 15:07 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®