From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 2/2] state: check return value of of_property_count_strings
Date: Wed, 23 Sep 2015 17:26:12 +0200 [thread overview]
Message-ID: <1443021972-18223-2-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1443021972-18223-1-git-send-email-s.hauer@pengutronix.de>
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>
---
common/state.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/common/state.c b/common/state.c
index 9f8ead1..117a686 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;
--
2.5.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2015-09-23 15:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-23 15:26 [PATCH 1/2] state: write names in enum32 variables to oftree again Sascha Hauer
2015-09-23 15:26 ` Sascha Hauer [this message]
2015-09-24 14:07 ` Marc Kleine-Budde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1443021972-18223-2-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox