[PATCH 3/3] fixup! state: add support for fixed length strings

Marc Kleine-Budde mkl at pengutronix.de
Thu Jun 25 05:47:11 PDT 2015


Only export default value if set. This may cause an NULL pointer deref.

Signed-off-by: Marc Kleine-Budde <mkl at pengutronix.de>
---
 common/state.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/common/state.c b/common/state.c
index 688c85cf0e7d..124332022662 100644
--- a/common/state.c
+++ b/common/state.c
@@ -445,14 +445,17 @@ static int state_string_export(struct state_variable *var,
 	struct state_string *string = to_state_string(var);
 	int ret = 0;
 
-	if (string->value_default || conv == STATE_CONVERT_FIXUP) {
+	if (string->value_default) {
 		ret = of_set_property(node, "default", string->value_default,
 				      strlen(string->value_default) + 1, 1);
 
-		if (ret || conv == STATE_CONVERT_FIXUP)
+		if (ret)
 			return ret;
 	}
 
+	if (conv == STATE_CONVERT_FIXUP)
+		return 0;
+
 	if (string->value)
 		ret = of_set_property(node, "value", string->value,
 				      strlen(string->value) + 1, 1);
-- 
2.1.4




More information about the barebox mailing list