summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-09-10 15:14:39 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2015-09-29 09:07:48 +0200
commite94d1eb5d313364d2659261c4658d37854eb9d70 (patch)
tree60c95c36fc9042c6cb2140910f44a7da86c1ba0f /common
parent2a34749fca7b05f09112fb42f7b6ac130eda1ebc (diff)
downloadbarebox-e94d1eb5d313364d2659261c4658d37854eb9d70.tar.gz
barebox-e94d1eb5d313364d2659261c4658d37854eb9d70.tar.xz
state: check return value of of_property_count_strings
When a enum32 state variable node does not have a "names" property bail out instead of continuing with an error value used as number of strings. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/state.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/common/state.c b/common/state.c
index 9f8ead1500..117a686759 100644
--- a/common/state.c
+++ b/common/state.c
@@ -318,6 +318,10 @@ static struct state_variable *state_enum32_create(struct state *state,
enum32 = xzalloc(sizeof(*enum32));
num_names = of_property_count_strings(node, "names");
+ if (num_names < 0) {
+ dev_err(&state->dev, "enum32 node without \"names\" property\n");
+ return ERR_PTR(-EINVAL);
+ }
enum32->names = xzalloc(sizeof(char *) * num_names);
enum32->num_names = num_names;