[PATCH 2/2] state: check return value of of_property_count_strings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux